2022-02-11 21:48:29 -06:00
|
|
|
use clap::Command;
|
2021-10-12 19:57:32 +01:00
|
|
|
|
|
|
|
fn main() {
|
2022-02-14 15:47:20 -06:00
|
|
|
let cmd = Command::new(env!("CARGO_CRATE_NAME"))
|
2022-05-02 06:21:52 -05:00
|
|
|
.multicall(true)
|
2022-02-10 11:51:40 -06:00
|
|
|
.arg_required_else_help(true)
|
2021-12-07 15:38:17 -06:00
|
|
|
.subcommand_value_name("APPLET")
|
|
|
|
.subcommand_help_heading("APPLETS")
|
2022-02-11 21:48:29 -06:00
|
|
|
.subcommand(Command::new("hostname").about("show hostname part of FQDN"))
|
|
|
|
.subcommand(Command::new("dnsdomainname").about("show domain name part of FQDN"));
|
2021-10-12 19:57:32 +01:00
|
|
|
|
2022-02-14 15:47:20 -06:00
|
|
|
match cmd.get_matches().subcommand_name() {
|
2021-10-12 19:57:32 +01:00
|
|
|
Some("hostname") => println!("www"),
|
|
|
|
Some("dnsdomainname") => println!("example.com"),
|
2021-11-12 09:12:32 -06:00
|
|
|
_ => unreachable!("parser should ensure only valid subcommand names are used"),
|
2021-10-12 19:57:32 +01:00
|
|
|
}
|
|
|
|
}
|