fix showing help for sub commands with custom executableFile #1018
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.
Problem
As of 3.0.0, the git-style executable sub commands can have
executableFile
option to customize the name of file containing the command.But running
help
for these kind of sub commands will return error as the built-inhelp
sub command will try to look executable files with default constructed name.Example in old version:
Solution
Turns out, this is because when we run
help
, it will be treated as any user defined sub commands with special treatment of switching the arguments in theexecuteSubCommand
function to make it as if we run our custom sub command using--help
flag (see here).This is incorrect behaviour since the
executeSubCommand
will further assume the executable file name with default constructed name, as the resolving mechanism of theexecutableFile
option is done at theparse
function.This PR fixes the problem by moving the "argument switching" mechanism to the
parse
function before the resolving mechanism is done, so theexecuteSubCommand
will get correct executable file name.