mirror of
https://github.com/clap-rs/clap
synced 2024-12-13 14:22:34 +00:00
03cb509d6c
This is to make room for a reasonable looking cargo plugin example. I got lazy and didn't update the tutorials.
18 lines
693 B
Rust
18 lines
693 B
Rust
use clap::{App, AppSettings};
|
|
|
|
fn main() {
|
|
let app = App::new(env!("CARGO_CRATE_NAME"))
|
|
.setting(AppSettings::ArgRequiredElseHelp)
|
|
.subcommand_value_name("APPLET")
|
|
.subcommand_help_heading("APPLETS")
|
|
.subcommand(App::new("hostname").about("show hostname part of FQDN"))
|
|
.subcommand(App::new("dnsdomainname").about("show domain name part of FQDN"));
|
|
|
|
let app = app.setting(AppSettings::Multicall);
|
|
|
|
match app.get_matches().subcommand_name() {
|
|
Some("hostname") => println!("www"),
|
|
Some("dnsdomainname") => println!("example.com"),
|
|
_ => unreachable!("parser should ensure only valid subcommand names are used"),
|
|
}
|
|
}
|