github jdx/usage v3.2.0
v3.2.0: Environment-backed choices and zsh escaping fix

6 hours ago

This release adds the ability to source argument/flag choices from environment variables at runtime and fixes a zsh completion regression where parentheses and brackets in task descriptions caused shell errors.

Added

  • Arguments and flags can now pull their allowed values from an environment variable using choices env=.... The env var value is split on commas and/or whitespace, deduplicated against any literal choices, and resolved at parse/completion time rather than baked into generated output. (#548 by @mustafa0x)

    arg "<env>" {
      choices env="DEPLOY_ENVS"
    }

    With DEPLOY_ENVS="foo,bar baz", valid values become foo, bar, and baz. You can also combine literal choices with env-backed ones:

    flag "--env <env>" {
      choices "local" env="DEPLOY_ENVS"
    }

    When the env var is unset or empty and no literal choices are provided, validation rejects all values with a clear error message. Help output and generated markdown surface the controlling env var name rather than snapshotting its current value.

    This feature is currently behind the unstable_choices_env feature flag in the library crate.

Fixed

  • Zsh completions now properly escape parentheses ((, )) and brackets ([, ]) in completion descriptions. Previously, these characters were passed through to zsh's _describe function unescaped, causing it to interpret them as glob qualifiers or character classes -- resulting in cryptic errors like unknown file attribute and unknown sort specifier. This was a regression from v2.x. If you have existing generated zsh completions, regenerate them to pick up this fix. (#559 by @jdx, fixes #558)

New Contributors

Full Changelog: v3.1.0...v3.2.0

Don't miss a new usage release

NewReleases is sending notifications on new releases.