Skip to content

Shell completion (bash/zsh) #4

Description

@trmxvibs

Context

pkgwrap now has 8 subcommands, 7 command aliases, 17 backends and several
flags. Tab completion would remove most of the remaining friction, and it's
the last unchecked item in the README roadmap that doesn't need a design
debate first.

Proposal

Add a hidden command that prints a completion script:

pkgwrap --completion bash
pkgwrap --completion zsh
pkgwrap --completion fish

Users wire it up themselves:

# bash
eval "$(pkgwrap --completion bash)"
# or
pkgwrap --completion bash | sudo tee /etc/bash_completion.d/pkgwrap

What should be completed

  • Subcommands and their aliases (install, in, add, remove, ...)
  • Flags (-y, --dry-run, --no-cache, --clear-cache, --version)
  • Values for --backend — generated from available_backends(), not
    hardcoded, so it doesn't go stale when a backend is added

Completing package names is explicitly out of scope for a first pass:
it would mean querying the package manager on every tab press, which is
slow and backend-specific. That belongs in its own issue if wanted later.

Constraints

  • No new runtime dependencies — pkgwrap has zero and that's a feature.
    Generate the script as a plain string; don't pull in argcomplete.
  • Must work on Python 3.9

Acceptance criteria

  • pkgwrap --completion <shell> prints a working script for bash, zsh, fish
  • Backend names in the output are derived from the registry
  • Tests assert every registered backend and subcommand appears in the output
  • README documents how to install the completion
  • Roadmap item checked off

Pointers

  • src/pkgwrap/cli.py — build_parser() and COMMAND_ALIASES
  • src/pkgwrap/backends/__init__.py — available_backends()

Activity

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

Metadata

Metadata

Labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions