use clap::{App, Arg, SubCommand, ArgMatches}; use crate::commands; use crate::commands::remote::RemoteArgs; pub fn create() -> App<'static, 'static> { SubCommand::with_name("remote") .about("Manage set of tracked repositories") .subcommand( SubCommand::with_name("add") .arg( Arg::with_name("name") .required(true) .index(1) .help("The name of the remote"), ) .arg( Arg::with_name("url") .required(true) .index(2) .help("The url of the remote"), ) .about("Add a new remote to this repository") ) .arg( Arg::with_name("verbose") .short("v") .long("verbose") .required(false) .takes_value(false) .help("Be a little more verbose and show remote url after name.") ) } pub fn handler(args: &ArgMatches<'_>) { match args.subcommand() { ("add", Some(add_matches)) => { commands::remote::remote_add(RemoteArgs { name: add_matches.values_of("name"), url: add_matches.values_of("url"), }); } _ => { commands::remote::remote_list(args.is_present("verbose")); } } }