use clap::{Arg, ArgAction, ArgMatches, Command}; use crate::commands; use crate::commands::add::AddArgs; use crate::config::config::Config; pub fn create() -> Command { Command::new("add") .arg( Arg::new("files") .required_unless_present("all") .conflicts_with("all") .num_args(1..) .value_name("FILE") .help("Files to add"), ) .arg( Arg::new("force") .short('f') .long("force") .action(ArgAction::SetTrue) .help("Allow adding otherwise ignored files."), ) .arg( Arg::new("all") .short('A') .long("all") .action(ArgAction::SetTrue) .help("This adds, modifies, and removes index entries to match the working tree"), ) .about("Add changes to the index") } pub fn handler(args: &ArgMatches) { commands::add::exec( AddArgs { files: match args.get_many::("files") { None => vec![], Some(vals) => vals.map(|s| s.to_string()).collect(), }, force: *args.get_one::("force").unwrap(), all: *args.get_one::("all").unwrap(), }, Config::new(), ); }