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

Remove __complete cmd for programs without subcmds #1563

Merged
merged 1 commit into from Dec 14, 2021

Conversation

marckhouzam
Copy link
Collaborator

Fixes #1562

Programs that don't have sub-commands can accept any number of args.
However, when doing shell completion for such programs, within the __complete command code this very __complete command makes it that the program suddenly has a sub-command, and the call to Find() -> legacyArgs() will then return an error if there are more than one argument on the command-line being completed.

To avoid this, we first remove the __complete command in such a case so as to get back to having no sub-commands.

A go test has been added.

See #1562 for program to reproduce the issue.

Fixes spf13#1562

Programs that don't have sub-commands can accept any number of args.
However, when doing shell completion for such programs, within the
__complete code this very __complete command makes it that the program
suddenly has a sub-command, and the call to Find() -> legacyArgs() will
then return an error if there are more than one argument on the
command-line being completed.

To avoid this, we first remove the __complete command in such a case so
as to get back to having no sub-commands.

Signed-off-by: Marc Khouzam <marc.khouzam@montreal.ca>
@jpmcb jpmcb merged commit 9054739 into spf13:master Dec 14, 2021
@marckhouzam marckhouzam deleted the fix/legacyArgsComp branch December 14, 2021 18:35
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

Successfully merging this pull request may close these issues.

Completion fails after the first argument for programs without sub-commands
2 participants