github jdx/usage v2.15.0
v2.15.0: Custom Environment Variable Handling

12 hours ago

This release introduces a new Parser builder API that gives you fine-grained control over how environment variables are resolved during argument parsing. Instead of relying on the default behavior of reading from std::env, you can now provide your own environment variable lookup function.

Highlights

Parser Builder for Custom Env Var Handling

The new Parser builder pattern (#464) allows you to customize how environment variables are resolved when parsing CLI arguments. This is particularly useful for:

  • Testing: Mock environment variables without modifying the actual environment
  • Sandboxed execution: Control which env vars are visible to the parser
  • Custom variable sources: Pull values from configuration files or other sources
let args = Parser::new(&spec, &argv)
    .with_env(|key| custom_env_lookup(key))
    .parse()?;

Internal Improvements

  • Added cargo-semver-checks to CI to automatically detect breaking API changes (#463) by @jdx
  • Improved test assertions using fish output format for cleaner test output (#461) by @ilyagr

For full documentation, visit usage.jdx.dev.

Don't miss a new usage release

NewReleases is sending notifications on new releases.