Skip to content

feat(cli): generate shell completion scripts (tth completions <shell>) #78

Description

@JoseVelazcoH

Problem

Thoth wires shell hooks via tth init, but there is no way to generate shell completion scripts. Users typing tth <TAB> get nothing, so subcommands, flags, and values (like theme names) are not discoverable from the shell.

Proposed solution

Add a tth completions <shell> command that prints a completion script to stdout, for bash, zsh, and fish. It should reuse the existing clap command definition so completions stay in sync automatically.

tth completions zsh > ~/.zfunc/_tth

Alternatives considered

  • Hand-written completion scripts - discarded: drift out of sync with the CLI on every flag change.
  • Bundling static scripts in the repo - discarded: same drift problem; generation from clap is the idiomatic Rust approach.

Acceptance criteria

  • tth completions <shell> prints a valid script for bash, zsh, and fish.
  • An unknown shell errors with a clear message listing valid values.
  • Generated from the live clap command (no duplicated definition).
  • README/docs mention how to install completions.
  • A smoke test asserts non-empty output per shell.

Scope

cli (new subcommand), Cargo.toml (clap_complete dependency), docs.

Additional context

clap_complete::generate is the standard tool. The CLI is defined with clap in src/cli.rs; expose the Command so both parsing and completion generation use it. Good first issue: mechanical and self-contained, no business logic.

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