Generate shell completions from the binary, with no new dependency
New command-line tools keep arriving as single binaries, and shell completion is the small tax each one pays before it feels installed. Trendshift's weekly view, retrieved 24 November 2026 for the week of 23 to 29 November, lists the experimental google-gemini/gemini-api-cli at 503 stars gained that week. The cli tag on dev.to carried a run of independent tool releases on 22 and 23 November,…
A new command-line tool, broom, provides shell completion without introducing additional dependencies. The experimental google-gemini/gemini-api-cli gained 503 stars in the week of 23 to 29 November 2026, highlighting the trend of small tools being released independently. However, users still need to manually integrate these tools into their shell.
Kolgrim33/broom#5 presents a solution by adding a --completions flag to broom, which generates completion scripts for bash, zsh, and fish shells without increasing the dependency tree. The implementation adds a new ParseOutcome::PrintCompletions(String) variant in src/cli.rs, which prints the generated completion script and returns ExitCode::SUCCESS before running the path validation, scan, or clean code.
The bash, zsh, and fish generators read the shared table of option descriptions and render the data into their respective syntaxes. The generated completion scripts are not committed to the repository, ensuring they remain up-to-date with the parser. The tests enforce that each shell receives the correct flags, values, and ecosystem IDs.
The approach adds 276 lines to the codebase and no dependencies to the build, as confirmed by the verification notes. The main limitation is that hand-written generators require maintenance, which may be a concern for larger CLIs with many flags.
Rewritten by urgent.news; may contain errors — check the original.
Source: dev.to