argone
Most intuitive global cli maker. *(lazy_static + config-rs + clap)

| Examples | Docs | Latest Note |
[dependencies]
argone = "0.3"
Phases
- Parsing
clap.
- If clap-argument is
Noneand the argument has [Config] markthen extract data from Config(file or env).
- When the data is extracted and that was empty,eventually set Default(=) value.
Example
* basics
use argone::{prelude::*, *};
ARGS! {
version = "0.1"
author = "just-do-halee <just.do.halee@gmail.com>"
about = "this is our application"
Config {
file = "examples/Config"
prefix = "APP"
}
Args {
name: String
[Config] age: Option<u8> = 12
#[clap(short, long)]
job: Vec<String>
#[clap(short, long, name = "WEIGHT")]
[Config] weight: Option<u8> = 50
#[clap(short, long, default_value = "1")]
verbose: u8
}
commands = Sub
}
COMMANDS! {
Sub {
First {
version = "1.0"
author = "just-do-halee <just.do.halee@gmail.com>"
Args {
test: String
}
}
Second {
about = "The second subcommand"
Args {
test: u8
}
}
}
}
fn main() {
println!("{:#?}", *ARGS);
if ARGS.name == "test" {
println!("name is test.");
}
if ARGS.age.unwrap() != 12 {
println!("age is not matching default 12.");
}
for job in &ARGS.job {
println!("{}", job);
}
println!(
"weight is {}\nverbose is {}",
ARGS.weight.unwrap(),
ARGS.verbose
);
if let Some(sub) = &ARGS.commands {
match sub {
Sub::First { test } => println!("first command: {}", test),
Sub::Second { test } => println!("second command: {}", test),
}
} else {
println!("none subcommands");
}
}