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 becomefoo,bar, andbaz. 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_envfeature 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_describefunction unescaped, causing it to interpret them as glob qualifiers or character classes -- resulting in cryptic errors likeunknown file attributeandunknown 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
- @mustafa0x made their first contribution in #548
Full Changelog: v3.1.0...v3.2.0