use clap::{App, Arg, SubCommand, ArgMatches}; use crate::commands::config::ConfigSetArgs; use crate::commands; pub fn create() -> App<'static, 'static> { SubCommand::with_name("config") .about("Get and set repository or global options") .subcommand( SubCommand::with_name("get") .about("Get the value of a configuration variable") .arg( Arg::with_name("name") .help("The name of the configuration variable") .required(true) .index(1) ) ) .subcommand( SubCommand::with_name("set") .about("Set a configuration variable") .arg( Arg::with_name("name") .help("The name of the configuration variable") .required(true) .index(1) ) .arg( Arg::with_name("value") .help("The value to set") .required(true) .index(2) ) ) } pub fn handler(args: &ArgMatches<'_>) { match args.subcommand() { ("set", Some(set_matches)) => { commands::config::config_set(ConfigSetArgs { name: set_matches.values_of("name"), value: set_matches.values_of("value"), }); } _ => println!("Invalid or missing subcommand for 'config'"), } // AddArgs { // files: args.values_of("files"), // force: args.is_present("force"), // all: args.is_present("all"), // }); }