Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Clap Template

Skeleton application to build cli tools using clap.

Adding Commands

To add new commands, copy the template folder:

$ cp -r template/ new_command/

Then rename the instances of Template in the copied mod.rs to your desired command name:

$ sed -i '' 's/Template/NewCommand/g' ./src/new_command/mod.rs

Include new_command in main.rs:

// [...]
mod new_command;
// [...]

And ensure it is available as a top level command:

// [...]
enum Commands {
    // [...]
    NewCommand(new_command::Command),
    // [...]
}
// [...]
fn main() {
    // [...]
    match cli.command {
        // [...]
        Some(Commands::NewCommand(command)) => {
            new_command::command(&command);
        },
        //[...]
    }
    // [...]
}

You can then try out your new command by running the application and invoking new_command:

$ cargo run -- new_command

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages