argenv-resolve 0.4.0

Resolve an argenv contract against a real invocation - argv and envp, with precedence, defaults, and linting. Depends on argenv for the declared data; argenv depends on nothing here.
Documentation

argenv-resolve

Resolve an argenv contract against a real invocation — argv and envp — with precedence, defaults, and linting.

argenv declares what a program accepts, as data, and does not read argv or envp at all. This crate is the other half. See the crate-level docs for the full picture.

use argenv_resolve::*;

contract! {
    HOST: String = Input {
        key: "host",
        ty:  Type::String,
        env: Some(Env::new("APP_HOST")),
        arg: Some(Arg { value_name: "HOST", ..Arg::long("host") }),
        ..Input::EMPTY
    };
}

fn main() {
    let resolved = Contract::parse_and_lint(OnProblems::FailOnError);
    let host = Contract::HOST.get_from(&resolved);
}

A misspelled flag or variable, and a flag given to the wrong subcommand, are errors by default; a program that wants to be more forgiving passes its own LintPolicy. The same declaration also derives shell completions and a man page (argenv_resolve::generate). Both are explained in the repository README.