mirror of
https://github.com/clap-rs/clap
synced 2024-12-13 22:32:33 +00:00
1428785677
This shouldn't be needed anymore now that this is effectively the new behavior for the non-deprecated actions. This was briefly talked about in https://github.com/clap-rs/clap/discussions/2627 but I wasn't familiar enough with the implementation to know how safe it is. Now, maintainrs and users can be more confident because they are explicitly opting into it. See also #3795
21 lines
576 B
Rust
21 lines
576 B
Rust
// Note: this requires the `cargo` feature
|
|
|
|
use clap::{arg, command, AppSettings, ArgAction};
|
|
|
|
fn main() {
|
|
let matches = command!()
|
|
.global_setting(AppSettings::DeriveDisplayOrder)
|
|
.allow_negative_numbers(true)
|
|
.arg(arg!(--two <VALUE>).action(ArgAction::Set))
|
|
.arg(arg!(--one <VALUE>).action(ArgAction::Set))
|
|
.get_matches();
|
|
|
|
println!(
|
|
"two: {:?}",
|
|
matches.get_one::<String>("two").expect("required")
|
|
);
|
|
println!(
|
|
"one: {:?}",
|
|
matches.get_one::<String>("one").expect("required")
|
|
);
|
|
}
|