Skip to content

Add shell completions (attempt completions <shell>) #1

Description

@nullarch

attempt is a clap-based CLI with a fairly deep subcommand tree (hook, sync, snapshot, keys, daemon, repair, import, …), and typing it without completion is tedious.

What to do

Add attempt completions <bash|zsh|fish|powershell|elvish> that writes a completion script to stdout, using clap_complete. The CLI is defined in crates/attempt/src/cli.rs (derive API), so clap_complete::generate needs Cli::command() and nothing else.

  • New file crates/attempt/src/cmd_completions.rs, wired in crates/attempt/src/main.rs next to the other Command:: arms.
  • Add clap_complete to [workspace.dependencies] in the root Cargo.toml and to crates/attempt/Cargo.toml. It is a build-time-only code generator with no transitive weight, so it does not threaten the single-binary rule — say so in the PR.
  • A unit test that generating for each shell produces non-empty output and does not panic.

Done when

attempt completions zsh | head prints a completion script, cargo test -p attemptdb passes, and README.md's install section mentions how to install completions.

Good first issue: self-contained, one new file, no design decisions.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions