github jdx/usage v3.5.7
v3.5.7: Mounted commands stop leaking mounting-CLI flags

latest releases: v4.0.0, v3.6.0
3 hours ago

A parser fix for shell completions inside mounted commands. Addresses jdx/mise#11282, where the mounting CLI's global flags leaked into mounted task completions and non-global flags before a task hid the task from the parser.

Fixed

  • Mounted commands no longer inherit the mounting CLI's flags (#738). Three related defects in how the partial-parse's subcommand scan and re-parse interact with mount:

    1. Globals leaked into mounted commands. For a CLI like mise, where everything after a task name is forwarded to the task, mise run mytask --<TAB> used to offer --cd --env --jobs --locked --quiet --raw --silent --verbose --yes even though the mounted program rejects them (unexpected word: --silent). Worse, when a mounted task declared a flag whose name collided with a global (e.g. its own --env with choices), the global shadowed it and value completion fell back to file paths instead of the task's choices. Mounted commands are now marked internally and their own flags take precedence over inherited globals for their own names; a new ParseOutput::completion_flags() returns just the flags a completion should offer once a mount boundary has been crossed. Globals stay recognized before the mounted command, and mount scripts still receive them.

    2. A non-global flag hid the subcommand behind it. Phase 1 stopped scanning at the first non-global flag, so usage complete-word ... -- mise run --force build --bump '' failed with unexpected word: build. Known non-global flags are now consumed like globals and the scan continues; they are simply not forwarded to mounts. Unknown flags still stop the scan since their arity is unknown.

    3. Re-parsed prefix words could bind to the wrong flag. A global's value that appeared before a mounted command with a same-named flag would be re-validated against the mounted flag's choices and rejected. Phase 1 now records which flag each skipped word was read as, and Phase 2 respects that binding, so mycli --env prod run task --env <TAB> still parses --env prod as the global and offers the task's --env choices after the task name.

    Documentation for global flags and mounted commands has been added under docs/spec/reference/.

Full Changelog: v3.5.6...v3.5.7

💚 Sponsor usage

usage is maintained by @jdx, an open source developer for entire.io, the title sponsor of the jdx.dev open source tools including mise, aube, hk, and more. Work on usage is funded by sponsorships.

If usage powers CLI specs, docs, or completions for a tool you maintain or use, please consider sponsoring at jdx.dev. Every sponsorship helps the project stay independent and moving.

Don't miss a new usage release

NewReleases is sending notifications on new releases.