Skip to content

Conversation

@tnk4on
Copy link
Contributor

@tnk4on tnk4on commented Dec 24, 2025

Summary

Add a hidden bootc completion <shell> subcommand that generates shell completion scripts for bash, zsh, and fish.

Motivation

This enables distributions (e.g., Fedora, CentOS Stream, RHEL) to generate and package shell completions during RPM/deb builds by calling:

bootc completion bash > /usr/share/bash-completion/completions/bootc
bootc completion zsh > /usr/share/zsh/site-functions/_bootc
bootc completion fish > /usr/share/fish/vendor_completions.d/bootc.fish

Implementation Details

  • Added CompletionShell enum with Bash, Zsh, and Fish variants
  • The completion scripts only include visible (non-hidden) subcommands intended for end users
  • Completed subcommands: edit, image, install, status, switch, update, upgrade, usroverlay
  • Uses clap::CommandFactory to introspect the CLI structure
  • Added clap_complete as a dev-dependency

Testing

  • Tested on Fedora container with cargo build
  • Tested RPM build on RHEL10-compatible environment
  • Verified completion works correctly in bash, zsh, and fish shells

@bootc-bot bootc-bot bot requested a review from ckyrouac December 24, 2025 01:33
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds a bootc completion command to generate shell completion scripts. The implementation is well-intentioned but manually generates the scripts, which is brittle and incomplete. I've provided feedback to use the clap_complete crate for a more robust and maintainable solution, which also aligns the implementation with the existing tests. I've also noted that clap_complete should be a regular dependency, not a dev-dependency, and pointed out some code duplication in the new tests.

@tnk4on tnk4on force-pushed the feature/shell-completion branch from 4676f0f to 1c81141 Compare December 24, 2025 15:37
@henrywang
Copy link
Collaborator

Could you please sign off commit which is required by DCO test and make a rebase to fix fedora-42 failure? Thank you and Happy New Year.

@tnk4on tnk4on force-pushed the feature/shell-completion branch 2 times, most recently from dd50060 to 0df21d6 Compare January 1, 2026 14:57
@cgwalters
Copy link
Collaborator

Also, thanks so much for working on this!!

@tnk4on tnk4on force-pushed the feature/shell-completion branch from 0df21d6 to b7a1551 Compare January 7, 2026 07:18
@github-actions github-actions bot added area/install Issues related to `bootc install` area/ostree Issues related to ostree labels Jan 7, 2026
@tnk4on tnk4on force-pushed the feature/shell-completion branch 2 times, most recently from c020978 to 0d7d745 Compare January 7, 2026 14:09
@tnk4on
Copy link
Contributor Author

tnk4on commented Jan 7, 2026

I've made a few updates before pushing:

  1. Local validation: Ran validation tests locally and fixed any issues before pushing to ensure the code is ready for review.

  2. Focused changes: Removed unrelated file changes that were accidentally included. The PR now focuses only on the shell completion feature.

@tnk4on tnk4on force-pushed the feature/shell-completion branch 2 times, most recently from 04df01c to 8594e46 Compare January 8, 2026 05:23
@cgwalters
Copy link
Collaborator

This enables distributions (e.g., Fedora, CentOS Stream, RHEL) to generate and package shell completions during RPM/deb builds by calling:

Also we do have a spec file here...so it'd likely be useful to actually do that change in it.

It looks like at least podman ships bash and fish completions by default. Also they ship a man page man podman-completion, which might make sense here.


Also I tested this out, it seems to work well but one thing I noticed I don't like is that it shows our hide=true subcommands. Digging in there's a ton of related issues/PRs in clap, of which clap-rs/clap#5283 is most relevant.

- Add completion subcommand supporting bash, zsh, and fish

Assisted-by: Cursor (Auto)
Signed-off-by: Shion Tanaka <[email protected]>
@tnk4on tnk4on force-pushed the feature/shell-completion branch from 8594e46 to 0211fe2 Compare January 8, 2026 21:22
@cgwalters cgwalters enabled auto-merge (rebase) January 8, 2026 21:34
@cgwalters cgwalters merged commit d2eb1b6 into bootc-dev:main Jan 8, 2026
45 of 47 checks passed
@tnk4on tnk4on deleted the feature/shell-completion branch January 9, 2026 01:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/install Issues related to `bootc install` area/ostree Issues related to ostree

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants