Skip to content

Conversation

@l1a
Copy link

@l1a l1a commented Dec 12, 2025

feat: add --completions flag for shell completion generation

Description

This PR adds a --completions <SHELL> flag to the ouch CLI. This allows users to generate shell completion scripts for supported shells (Bash, Elvish, Fish, PowerShell, Zsh) directly from the binary.

This is useful for package maintainers and users who want to manually set up completions without relying on the build script artifacts.

Changes

  • Cargo.toml: Added clap_complete to runtime dependencies.
  • src/cli/args.rs: Added completions option to CliArgs and made cmd subcommand optional (to allow running ouch --completions ... without a subcommand).
  • src/cli/mod.rs: Implemented completion generation logic. Added runtime check to ensure cmd is present if --completions is not used.
  • src/commands/mod.rs: Updated to handle Option<Subcommand>.
  • tests: Added unit tests for the new flag and updated UI tests.
  • Docs: Updated README.md and CHANGELOG.md.

Verification

  • Run ouch --completions bash to see the generated script.
  • All tests passed (cargo test).

l1a added 4 commits December 11, 2025 22:44
# Please enter a commit message to explain why this merge is necessary,
# especially if it merges an updated upstream into a topic branch.
#
# Lines starting with '#' will be ignored, and an empty message aborts
# the commit.
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.

1 participant