Skip to content

feat(cli): Add a subcommand to generate shell completions#74

Open
kunzaatko wants to merge 5 commits intoelkowar:mainfrom
kunzaatko:shell-completions
Open

feat(cli): Add a subcommand to generate shell completions#74
kunzaatko wants to merge 5 commits intoelkowar:mainfrom
kunzaatko:shell-completions

Conversation

@kunzaatko
Copy link

@kunzaatko kunzaatko commented Feb 13, 2026

Adds a subcommand to generate shell completions using clap_complete.
It is quite straight forward.

demo

Next steps:

  • Add a note to the docs for the feature under the CLI section
  • Add completion generation to the build scripts or generate in CI/CD and commit if changed as an asset (@elkowar
    what is your preference here?)
  • Add some hints for the subcommands such as yolk edit ... should complete the eggs, yolk git ... should
    complete git commands under the yolk directory and similar
  • Hide the hidden subcommand that is shown in the completions but is hidden from the help section

@kunzaatko
Copy link
Author

Currently there is no way to hide the subcommand in the completion.
clap-rs/clap#5214

@kunzaatko
Copy link
Author

kunzaatko commented Feb 14, 2026

Note to self: The completion for git works for pass such that pass git completes similarly to git. We can see how they achieve that there.
https://github.com/zx2c4/password-store/

@kunzaatko
Copy link
Author

kunzaatko commented Feb 15, 2026

Currently there is no way to hide the subcommand in the completion. clap-rs/clap#5214

Note to Self: The new Rust native completion system in clap has the ability to hide the hidden commands.
clap-rs/clap#3166

Rust native completions mean that the parsing and logic of the
completions of the flags and subcommands itself is done within Rust and
only the completion statements are passed to the shell.

This should be more stable and up to date since the completion can
change with new builds. Clap implements this as a modern approach and it
already has more features and capabilities than the static completion
script generation.

It also fixes the issue with hiding the `root-manage-symlinks`
subcommand from the completion.
It should support the `git` subcommand command completion feature.

Add it to the docs to let the users choose.
@kunzaatko
Copy link
Author

I currently wasn't able to add the git subcommand using clap either using the generated script or using the native completions. It should be set up correctly. The tracking issue is this one: github.com/clap-rs/clap/discussions/5214.

Let me know, whether it is desired to generate the shell-completions in the build scripts. Otherwise this PR is ready to merge 🚀

@kunzaatko kunzaatko marked this pull request as ready for review February 17, 2026 21:59
@fepfitra
Copy link
Contributor

Damn 2 weeks ago and still not merged yet :(

@kunzaatko
Copy link
Author

Elko hasn't been active for some time on GitHub it seems. @fepfitra Lets wait some more. Perhaps he is on holiday. We should respect his personal time... I will ping him (or you can) if there is no activity for more than a month.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants