Last active
October 12, 2017 17:18
-
-
Save codeword/f2d33edc566b8bf9de304b02179b177c to your computer and use it in GitHub Desktop.
Allows `--help` option anywhere in command line
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ThorHelpCatcher | |
def self.start(thor_clazz, args) | |
help_flag = (args & %w[--help -h])[0] | |
return thor_clazz.new.help(args.index(help_flag) == 0 ? args[1] : args[0]) if help_flag | |
thor_clazz.start(args) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
usage:
this will look like:
Note: if you want the --help option (
[--help], [--no-help] # Describe available commands or one specific command
) to show when helps are being shown you can also add a class option to the Thor subclass as in the example above