cor-args
A Rust library providing Chain of Responsibility command line argument parsing.
Examples
Example 1
The following example will assign config_path according to the following sequence:
- Look for a command-line argument named
--config - Look for an environment variable named
MYAPP_config - Default to
~/.config/myapp/default.yaml
// Don't forget to add `clap` to your `Cargo.toml`
let args = new
.arg
.get_matches;
let config_path = new
.next;
.handle_request;
let config_path = config_path.expect;
Example 2
The following example will assign some_value according to the following sequence:
- Look for a command-line argument named
--some_key - Look for an environment variable named
MYAPP_some_key - The contents of the file
/path/to/file.txt - Look for a key within
file.jsonnamedsome_key - Default to
"some_value"
// Don't forget to add `clap` to your `Cargo.toml`
let args = new
.arg
.get_matches;
let handler = new
.next;
let some_value = handler.handle_request;