Skip to content

pgoodjohn/clap-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commits
 
 
 
 
 
 
 
 
 
 

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

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages