cor-args 0.1.0

A Rust library providing Chain of Responsibility command line argument parsing.
Documentation

cor-args

A Rust library providing Chain of Responsibility command line argument parsing.

Example

The following example will assign config_path according to the following:

  1. Look for a command-line argument named --config
  2. Look for an environment variable named MYAPP_config
  3. Default to ~/.config/myapp/default.yaml
let args = clap::Command::new("myapp")
    .arg(clap::Arg::new("config").long("config"))
    .get_matches();

let config_path = ArgHandler::new(&args)
    .next(
        EnvHandler::new()
        .prefix("MYAPP_")
        .next(
            DefaultHandler::new("~/.config/myapp/default.yaml").into()
        ).into()
    );
    .handle_request("config");
let config_path = config_path.expect("No config path");