mirror of
https://github.com/clap-rs/clap
synced 2024-12-13 22:32:33 +00:00
62d7a3a928
- `PossibleValue::hidden` -> `PossibleValue::hide` (new in clap3, no breakin change) Fixes #33
31 lines
668 B
Rust
31 lines
668 B
Rust
//! Usage example of `arg_enum`
|
|
//!
|
|
//! All the variants of the enum and the enum itself support `rename_all`
|
|
|
|
use clap::{ArgEnum, Parser};
|
|
|
|
#[derive(ArgEnum, Debug, PartialEq, Clone)]
|
|
enum ArgChoice {
|
|
/// Descriptions are supported as doc-comment
|
|
Foo,
|
|
// Renames are supported
|
|
#[clap(name = "b-a-r")]
|
|
Bar,
|
|
// Aliases are supported
|
|
#[clap(alias = "b", alias = "z")]
|
|
Baz,
|
|
// Hiding variants from help and completion is supported
|
|
#[clap(hide = true)]
|
|
Hidden,
|
|
}
|
|
|
|
#[derive(Parser, PartialEq, Debug)]
|
|
struct Opt {
|
|
#[clap(arg_enum)]
|
|
arg: ArgChoice,
|
|
}
|
|
|
|
fn main() {
|
|
let opt = Opt::parse();
|
|
println!("{:#?}", opt);
|
|
}
|