-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
DefaultCommand does not work when defined on a sub-Command #1880
Comments
I've got a DefaultCommand on this sub-command which does not work: https://github.com/RealImage/bifrost/blob/36e773d2adcd2be64e69b871a80964829e6c2683/cmd/bf/ca.go#L28 |
@ananthb Can you show me how you are invoking the command ? |
In that example above, I can invoke the Neither option actually invokes the default command on If I run |
Ah ok so you want a default command on subcommand to flow through to the root. Thats not how it works. It works only one level. so a |
This might be simplistic but I thought of it as if a command has a default, then it should be executed if there are no arguments. Currently if a command at any level is run without arguments, this lib prints a help message. Setting a default command should replace that right? |
Not really. If you have required flags then yes it would print a help otherwise at that level the default command is run. If it doesnt then its a bug. Can you share a small code snipped that shows this ? |
I expected this example to print How can I get it to print |
You need to do something like this |
Perfect, thanks! |
Checklist
What problem does this solve?
This maybe a bug. DefaultCommand should work on sub-commands too.
Solution description
If any Command anywhere has sub-commands and a DefaultCommand, then that should run by default.
Describe alternatives you've considered
None
The text was updated successfully, but these errors were encountered: