Skip to content

Expose clap's shell completion generation methods via CLI #310

@ed9w2in6

Description

@ed9w2in6

Who, What, and Why

As a user,
I want shell completion,
so that I do not need to memorise the CLI or rely on the CLI's help utility.
--> This allows a smoother CLI usage experience and potentially further improves CLI discoverability.

Specific scenarios:

  • subcommand completion
    • there are a lot of subcommands, will be great to be able to search through them and list them all out temporarily with shell completions
  • option completion
    • same reasoning as above
  • argument completion
    • subcommands such as spotify_player get key <key> have arguments with specific values. Since they are nicely named but long, completion can speed this up by reducing risk of typo.

shell completion: custom TAB-completion available for some shells that requires custom script provided by the CLI program
some shells: clap_complete 4.4.4 provides bash, elvish, fish, powershell and zsh

How (roughly)

new dependencies

implementation directions

  1. provide subcommand that prints to stdout
    • The documentation above included an example implementation that prints completion script to stdout.
  2. generate at build time

When

NOT urgent.
The CLI is already very much usable at the current state.

Other informations

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions