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