When building CLI tools, shell completion usually treats each option in isolation.
Uncategorized
2
Posts
1
Posters
4
Views
-
When building CLI tools, shell completion usually treats each option in isolation. But sometimes valid values for one option depend on another—like branch names depending on which repository you're targeting.
Wrote about how I solved this in Optique, a type-safe CLI parser for TypeScript.
https://hackers.pub/@hongminhee/2026/optique-context-aware-cli-completion
-
CLIツールを作ってると、「
--repoで指定したリポジトリのブランチだけ補完候補に出したい」みたいな場面があるんですよね。でも普通のCLIパーサーだと各オプションが独立してて、これが意外と難しい。TypeScript向け型安全CLIパーサーOptiqueで、この問題を解決する仕組みを作ったので、記事にまとめました。