Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Completion error when no custom commands #10

Closed
grymoire7 opened this issue Jan 6, 2023 · 4 comments
Closed

Completion error when no custom commands #10

grymoire7 opened this issue Jan 6, 2023 · 4 comments

Comments

@grymoire7
Copy link

grymoire7 commented Jan 6, 2023

Errors are returned using tab completion for cmd when no --commands option was provided to garden completion zsh. Other command completions appear to work. Command completion for cmd also appears to work without error after completions are generated with the --commands option. Reproduction steps:

$ uname -mrs
Darwin 21.6.0 x86_64

$ zsh --version
zsh 5.8.1 (x86_64-apple-darwin21.0)

$ garden --version
garden 0.5.0-beta

$ garden completion zsh > $DIR_IN_FPATH/_garden  # no --commands option given

$ garden cmd <tab>
_arguments:comparguments:325: doubled rest argument definition: *::arguments -- Arguments to forward to custom commands:
_arguments:comparguments:325: doubled rest argument definition: *::arguments -- Arguments to forward to custom commands:
_arguments:comparguments:325: doubled rest argument definition: *::arguments -- Arguments to forward to custom commands:

$ garden help <tab>
cmd         -- Run custom commands over gardens
completion  -- Generate shell completions
eval        -- Evaluate garden expressions
exec        -- Run commands inside garden environments
grow        -- Grow garden worktrees into existence
help        -- Print this message or the help of the given subcommand(s)
init        -- Initialize a "garden.yaml" garden configuration file
inspect     -- Query tree status
list        -- List available gardens, groups, trees and commands
plant       -- Add pre-existing worktrees to a garden configuration file
prune       -- Remove unreferenced Git repositories
shell       -- Open a shell in a garden environment
@davvid
Copy link
Member

davvid commented Jan 8, 2023

I ran into that bug with the completion for garden cmd as well. I believe this upstream issue is the root cause:

clap-rs/clap#3022

garden cmd is setup the same way as the reproducer in that issue.

When I ran into it I didn't realize that it might be working with --commands so I'll have to give that a try.

If the upstream issues don't get traction then I might just end up manually writing the completions myself, but I've got hope that progress will be made. 🤞

I'll document this shortcoming for now and see if there's anything we can do on our side to deal with it.

@davvid
Copy link
Member

davvid commented Jan 8, 2023

clap-rs/clap#3166 looks like it's the headline epic issue that's being used to drive the features forward. We'll have to keep an eye on that one as well.

@davvid davvid closed this as completed in ff003ab Jan 8, 2023
davvid added a commit that referenced this issue Jan 8, 2023
Related-to: #10
Signed-off-by: David Aguilar <davvid@gmail.com>
@davvid
Copy link
Member

davvid commented Jan 8, 2023

I was able to come up with a workaround that should hold us over for now. It's not built-in (it requires an extra shell pipeline step) so I documented it and linked to the upstream issue from the documentation.

The fix is simple enough to apply, though. Hope that helps.

https://davvid.github.io/garden/commands.html#zsh

@davvid
Copy link
Member

davvid commented Jan 9, 2023

I believe I may have fixed the upstream issue in clap-rs/clap#4612

This would be a great fix to have in place before this feature is released so I'm hoping the fix gets merged soon. Once it's merged we won't need our grep workaround.

davvid added a commit that referenced this issue Jan 13, 2023
Add value hints and a value terminator so that the clap completion system
can use that to generate correct completions for "garden exec",
"garden cmd" and "garden <custom>" commands.

Related-to: #10
Signed-off-by: David Aguilar <davvid@gmail.com>
davvid added a commit that referenced this issue Jan 21, 2023
Related-to: #10
Related-to: clap-rs/clap#3022
Related-to: clap-rs/clap#4624
Signed-off-by: David Aguilar <davvid@gmail.com>
davvid added a commit that referenced this issue Jan 21, 2023
Now that clap-rs/clap#4624 was merged we can use value_terminator to fix the
zsh completions for commands that use two consecutive multi-valued arguments.

A more complete solution may arrive in clap-rs/clap#4612 but until that is
merged we can use this solution for now. If that change is ever merged then
we can bump our clap_complete version and remove our use of value_terminator.

Related-to: #10
Related-to: clap-rs/clap#3022
Related-to: clap-rs/clap#4624
Signed-off-by: David Aguilar <davvid@gmail.com>
davvid added a commit that referenced this issue Jan 21, 2023
Related-to: #10
Signed-off-by: David Aguilar <davvid@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants