add default executable (subcommand) option #415
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR introduces an option for the
.command()
call that allows git-style subcommands to default to a specific command in the event one isn't provided on the command line.The use case that brought about this PR was a build system I'm developing needing to run the subcommand
build
automatically when nothing was specified on the command line. I'm sure there is a hack that could have done this with.action()
but alas I wanted it to work with the executable functionality (i.e. having another script to do run the command).I'm sure I'm not the only one who can find a use case for this.
Test is included (based off of the pm-subcommand test) and shouldn't interfere with the existing test.
Also added some documentation (including documentation for the previously undocumented
opts.noHelp
option).I tried to keep the implementation as minimal as possible. Let me know if I need to change anything.