Skip to content

Instantly share code, notes, and snippets.

@ryansch
Created June 28, 2023 12:54
Show Gist options
  • Save ryansch/ab8d46b87d6e34b2cc3da8a036fa4a39 to your computer and use it in GitHub Desktop.
Save ryansch/ab8d46b87d6e34b2cc3da8a036fa4a39 to your computer and use it in GitHub Desktop.
ThorHelp (doesn't work with required options)
module ThorHelp
# This adds a --help option to all Thor commands.
def self.included(base)
base.class_eval do
class_option :help,
type: :boolean,
aliases: ["-h"],
desc: "Describe command"
class_before :check_help
no_commands do
def check_help
if options[:help]
help(@_invocations[self.class].first)
exit
end
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment