Prevent default command from running when user specifies an unknown command
roberts1000 opened this issue · 4 comments
If I use default_command
, any time someone runs an unknown command, Commander executes the default command. Is there any way to make Commander operate similar to bundler, and have it throw an error in this situation? I only want it run the default command when no sub command is specified.
$ bundle unknown_command
Could not find command "unknown_command".
$ bundle
Fetching gem metadata from https://rubygems.org/........
I'm afraid that's the way the feature is designed to work. I'm not sure if it's a good idea to change that as it could break the way people expect it to work. I'm open to being convinced, though. 😄
Thanks for confirming. Could we potentially have default_command
take an optional argument that can change the behavior?
default_command :foo, strict: true
Then the old behavior can continue to work as-is, but people can opt-in to the new behavior if they want it.
Yeah, something like that sounds reasonable. Would you like to take a stab at implementing that and make a pull request?
Sounds good. I'll take a look as soon as I can. Thanks for considering the enhancement.