Command-line application framework.
Example
A simple command-line application could look something like this:
use rawcmd::{Command, Flag, Intent};
fn main() {
match Command::with_name("foo")
.with_description("Command 1")
.with_flag(
Flag::with_name("flag1")
.with_alias("f1")
.with_description("Flag 1")
)
.with_subcommand(
Command::with_name("bar")
.with_description("Command 1:1")
.with_flag(
Flag::with_name("flag2")
.with_alias("f2")
.with_description("Flag 2")
)
.with_resolver(|_| Ok(2))
)
.with_resolver(|_| Ok(3))
.run()
{
Ok(code) => {
println!("Success: {:?}", code);
std::process::exit(0);
},
Err(error) => {
println!("Error: {:?}", error);
std::process::exit(1);
},
}
}
The function with_resolver
accepts closures and function pointers:
command.with_resolver(|_| Ok(1))
fn resolver(_: Intent) -> rawcmd::Result<usize> { Ok(2) }
command.with_resolver(&resolver)
TO-DO
- Support command inputs (e.g.
cli command <input0> <input1>
).