| 1 | use clap::Command; |
| 2 | |
| 3 | fn main() { |
| 4 | let cmd = Command::new(env!("CARGO_CRATE_NAME" )) |
| 5 | .multicall(true) |
| 6 | .arg_required_else_help(true) |
| 7 | .subcommand_value_name("APPLET" ) |
| 8 | .subcommand_help_heading("APPLETS" ) |
| 9 | .subcommand(Command::new("hostname" ).about("show hostname part of FQDN" )) |
| 10 | .subcommand(Command::new("dnsdomainname" ).about("show domain name part of FQDN" )); |
| 11 | |
| 12 | match cmd.get_matches().subcommand_name() { |
| 13 | Some("hostname" ) => println!("www" ), |
| 14 | Some("dnsdomainname" ) => println!("example.com" ), |
| 15 | _ => unreachable!("parser should ensure only valid subcommand names are used" ), |
| 16 | } |
| 17 | } |
| 18 | |