119625d8cSopenharmony_ciuse clap::Command; 219625d8cSopenharmony_ci 319625d8cSopenharmony_cifn main() { 419625d8cSopenharmony_ci let cmd = Command::new(env!("CARGO_CRATE_NAME")) 519625d8cSopenharmony_ci .multicall(true) 619625d8cSopenharmony_ci .arg_required_else_help(true) 719625d8cSopenharmony_ci .subcommand_value_name("APPLET") 819625d8cSopenharmony_ci .subcommand_help_heading("APPLETS") 919625d8cSopenharmony_ci .subcommand(Command::new("hostname").about("show hostname part of FQDN")) 1019625d8cSopenharmony_ci .subcommand(Command::new("dnsdomainname").about("show domain name part of FQDN")); 1119625d8cSopenharmony_ci 1219625d8cSopenharmony_ci match cmd.get_matches().subcommand_name() { 1319625d8cSopenharmony_ci Some("hostname") => println!("www"), 1419625d8cSopenharmony_ci Some("dnsdomainname") => println!("example.com"), 1519625d8cSopenharmony_ci _ => unreachable!("parser should ensure only valid subcommand names are used"), 1619625d8cSopenharmony_ci } 1719625d8cSopenharmony_ci} 18