0.3.4 - This version may not be safe as it has not been updated for a long time. Find out if your coding project uses this component and get notified of any reported security vulnerabilities with Meterian-X Open Source Security Platform
Maintain your licence declarations and avoid unwanted licences to protect your IP the way you intended.
MIT - MIT Licensearg_enum!
from clap
In Cargo.toml
:
[dependencies]
arg_enum_proc_macro = "0.3"
In the rust code:
use arg_enum_proc_macro::ArgEnum;
/// All the possible states of Foo
#[derive(ArgEnum)]
pub enum Foo {
/// Initial state
Unk,
/// Foo is on
On,
/// Foo is off
Off,
}
It is possible to express an alias using the attribute arg_enum(alias = "AliasVariant")
.
The FromStr
will map the "AliasVariant" string to the decorated enum variant:
/// All the possible states of Foo
#[derive(ArgEnum)]
pub enum Foo {
/// Initial state
Unk,
/// Foo is on
#[arg_enum(alias = "Up")]
On,
/// Foo is off
#[arg_enum(alias = "Down")]
Off,
}