2021-10-12 18:57:32 +00:00
|
|
|
use clap::{App, AppSettings};
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let app = App::new(env!("CARGO_CRATE_NAME"))
|
|
|
|
.setting(AppSettings::ArgRequiredElseHelp)
|
2021-12-07 21:38:17 +00:00
|
|
|
.subcommand_value_name("APPLET")
|
|
|
|
.subcommand_help_heading("APPLETS")
|
2021-11-12 15:12:32 +00:00
|
|
|
.subcommand(App::new("hostname").about("show hostname part of FQDN"))
|
2021-10-12 18:57:32 +00:00
|
|
|
.subcommand(App::new("dnsdomainname").about("show domain name part of FQDN"));
|
|
|
|
|
2021-10-15 19:59:33 +00:00
|
|
|
let app = app.setting(AppSettings::Multicall);
|
|
|
|
|
2021-10-12 18:57:32 +00:00
|
|
|
match app.get_matches().subcommand_name() {
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|