use cmder::{ParserMatches, Program};
fn main() {
let mut program = Program::new();
program
.author("vndaba")
.description("A simple demo cli")
.bin_name("demo")
.version("0.1.0");
program
.subcommand("greet")
.argument("<name>", "Pass the name to say hello to")
.alias("g")
.description("Simply greets the provided name")
.option("-c --custom <GREETING...>", "Pass a custom greeting to use")
.action(cmd::greet_cb);
program.parse();
}
mod cmd {
use super::*;
pub fn greet_cb(m: ParserMatches) {
let name = m.get_arg("<name>").unwrap();
let mut greeting = "Ahoy!".to_owned();
if let Some(custom_grtng) = m.get_option_arg("<GREETING...>") {
greeting = custom_grtng;
}
println!("{greeting} {name}");
}
}