Skip to content

Remove __complete cmd for programs without subcmds#1563

Merged
jpmcb merged 1 commit intospf13:masterfrom
VilledeMontreal:fix/legacyArgsComp
Dec 14, 2021
Merged

Remove __complete cmd for programs without subcmds#1563
jpmcb merged 1 commit intospf13:masterfrom
VilledeMontreal:fix/legacyArgsComp

Conversation

@marckhouzam
Copy link
Copy Markdown
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