-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Add default completion command even if there are no other sub-commands #1559
base: main
Are you sure you want to change the base?
Conversation
Yep, seems to work nicely, thanks! An observation is that as the |
Nice attention to detail! The completions should work for hidden commands. In this case however, when we call the "__complete" command to get the completions, we don't create the "completion" command so its subcommands don't get completed. Let me try to see if I can fix it. |
This PR is being marked as stale due to a long period of inactivity |
This looks good, was just about to dig into this myself. Thanks! |
I've let this rot for too long. Let's plan it for the next release. Come August iI will run some tests on it and make sure it is good. |
anything I can do to help getting this merged? |
bc8a1d0
to
10702a4
Compare
10702a4
to
d1660cf
Compare
I've finally re-worked this and I believe it is ready. |
When a program has no sub-commands, its root command can accept arguments. If we add the default "completion" command to such programs they will now have a sub-command and will no longer accept arguments. What we do instead for this special case, is only add the "completion" command if it is being called, or if it is being completed itself. We want to have the "completion" command for such programs because it will allow the completion of flags and of arguments (if provided by the program). Signed-off-by: Marc Khouzam <[email protected]>
d1660cf
to
b1acb50
Compare
@jpmcb When you have moment, this is ready for review. Don't hesitate to ask for clarifications. |
This supersedes #1450 and #1392
When a program has no sub-commands, its root command can accept arguments. If we add the default "completion" command to such programs they will now have a sub-command and will no longer accept arguments.
What we do instead for this special case, is only add the "completion" command if it is being called.
We want to have the "completion" command for such programs because it will allow the completion of flags and of arguments (if provided by the program).
@scop can you confirm this is what you were hoping for?
Testing done