Skip to content

[Feature] Add option to print Bash completion scriptΒ #558

@hdwalters

Description

@hdwalters

Is your feature request related to a problem? Please describe.
A lot of Bash CLI tools provide a command line option to output a completion script. For example, ripgrep provides an option:

$ rg --generate=complete-bash | head -5
_rg() {
  local i cur prev opts cmds
  COMPREPLY=()
  cur="${COMP_WORDS[COMP_CWORD]}"
  prev="${COMP_WORDS[COMP_CWORD-1]}"

This can be called in a .bashrc file, to enable command line completion:

source <(rg --generate=complete-bash)

It would be nice if Amber supported this.

Describe the solution you'd like
Since we already use the clap library, we can use the complementary clap_complete library to do this.

Describe alternatives you've considered
N/A

Additional context
See https://docs.rs/clap_complete/latest/clap_complete/ for more details.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions