mirror of
https://github.com/clap-rs/clap
synced 2024-12-14 14:52:33 +00:00
befee6667b
This creates distinct tutorial examples from complex feature examples (more how-tos). Both sets are getting builder / derive versions (at least the critical ones).
31 lines
1 KiB
Rust
31 lines
1 KiB
Rust
use std::process::exit;
|
|
|
|
use clap::{App, AppSettings, Arg};
|
|
|
|
fn main() {
|
|
let app = App::new(env!("CARGO_CRATE_NAME"))
|
|
.setting(AppSettings::ArgRequiredElseHelp)
|
|
.arg(
|
|
Arg::new("install")
|
|
.long("install")
|
|
.help("Install hardlinks for all subcommands in path")
|
|
.exclusive(true)
|
|
.takes_value(true)
|
|
.default_missing_value("/usr/local/bin")
|
|
.use_delimiter(false),
|
|
)
|
|
.subcommand(App::new("true").about("does nothing successfully"))
|
|
.subcommand(App::new("false").about("does nothing unsuccessfully"));
|
|
|
|
let app = app.setting(AppSettings::Multicall);
|
|
let matches = app.get_matches();
|
|
if matches.occurrences_of("install") > 0 {
|
|
unimplemented!("Make hardlinks to the executable here");
|
|
}
|
|
|
|
match matches.subcommand_name() {
|
|
Some("true") => exit(0),
|
|
Some("false") => exit(1),
|
|
_ => unreachable!("parser should ensure only valid subcommand names are used"),
|
|
}
|
|
}
|