Skip to content

Commit

Permalink
doc: document how to fix the zsh completion for "garden cmd"
Browse files Browse the repository at this point in the history
`garden cmd <TAB>` generates an error on zsh:

    _arguments:comparguments:325: doubled rest argument definition:
    *::arguments -- Arguments to forward to custom commands:

The root cause of the issue is that the generated completion script
contains two `*::` entries in the `garden cmd` arguments:

    '*::commands -- Custom commands to run over the resolved trees:' \
    '*::arguments -- Arguments to forward to custom commands:' \

A simple workaround is to drop the 2nd `*::arguments` entry.
Use a `grep` filter to workaround the zsh completion bug from
clap-rs/clap#3022 for now.

Document the workaround and add link to the issue.

Closes #10
Related-to: clap-rs/clap#3022
Signed-off-by: David Aguilar <davvid@gmail.com>
  • Loading branch information
davvid committed Jan 8, 2023
1 parent 8626145 commit ff003ab
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions doc/src/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -524,15 +524,17 @@ zsh shell completion script.

```bash
mkdir -p ~/.config/zsh/completion
garden completion zsh >~/.config/zsh/completion/_garden
garden completion zsh |
grep -v \*::arguments >~/.config/zsh/completion/_garden
```

Use `garden completion --commands zsh` instead of `garden completion zsh`
to include completions for custom commands.

*NOTE*: You will should regenerate the `_garden` zsh completion script
whenever `garden` is upgraded to ensure that all of the options and commands have
up to date completions.
The `grep` filter is needed to workaround [clap #3022](https://github.com/clap-rs/clap/issues/3022).

*NOTE*: You should regenerate the `_garden` zsh completion script whenever `garden`
is upgraded to ensure that all of the options and commands have up to date completions.

### Bash

Expand All @@ -554,7 +556,9 @@ Tab completion can only be made to include a static set of user-defined commands
Custom commands cannot be defined dynamically, which means that the same completions
will be used irrespective of your current directory.

Improvements to the shell completions can be made once traction has been made on this
upstream issue:
Improvements to the shell completions can be made once traction has been made on the
following upstream issues:

* [clap #3022](https://github.com/clap-rs/clap/issues/3022) - zsh broken with two multi length arguments

* [clapng #92](https://github.com/epage/clapng/issues/92) - Dynamic completion support

0 comments on commit ff003ab

Please sign in to comment.