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で、この問題を解決する仕組みを作ったので、記事にまとめました。

https://zenn.dev/hongminhee/articles/aedde5d7fcc40e

0

If you have a fediverse account, you can quote this note from your own instance. Search https://hollo.social/@hongminhee/019bb5e0-011b-7b8c-ac3d-55d611c35560 on your instance and quote it. (Note that quoting is not supported in Mastodon.)