argopt
This crate provides attribute macros for command-line argument parsing.
Usage
Just by adding an attribute #[cmd] to a function, the function is converted to a command line program.
The output is:
$ cargo run
error: The following required arguments were not provided:
<host>
<port>
USAGE:
argopt-test <host> <port>
You can customize the behavior of arguments by annotating them with attributes.
And you can add help messages by adding doccomments.
/// Sample program
The output is:
argopt-test 0.1.0
Sample program
USAGE:
simple [OPTIONS] --host <host>
FLAGS:
--help Prints help information
-V, --version Prints version information
OPTIONS:
-h, --host <host> Host name
-p, --port <port> Port number [default: 80]
You can use the same options as structopt.
Subcommands
You can create sub commands by adding the attribute #[subcmd] to functions.
Easy Verbosity Level Handling
There is a feature that allows you to interact with the log crate and handle the verbosity level automatically.
The output is:
$ cargo run
This is error
$ cargo run -- -v
This is error
This is warn
$ cargo run -- -vv
This is error
This is warn
This is info
$ cargo run -- -vvv
This is error
This is warn
This is info
This is debug
$ cargo run -- -vvvv
This is error
This is warn
This is info
This is debug
This is trace
License: MIT