-
Notifications
You must be signed in to change notification settings - Fork 554
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
class_options in thor groups do not print in command help #661
Comments
I came up with a workaround to this by overriding the Here's a abbreviated example: class Base < Thor
register(BuildThor, "build", "build", "Build your site")
register(ServeThor, "serve", "serve", "Serve your site locally")
desc "help <command>", "Show detailed command usage information and exit"
def help(subcommand = nil)
if subcommand && respond_to?(subcommand)
klass = Kernel.const_get("Bridgetown::Commands::#{subcommand.capitalize}Thor")
klass.start(["-h"])
else
puts "Bridgetown is a Webpack-aware, Ruby-powered static site generator for the modern Jamstack era"
puts ""
puts "Version: #{Bridgetown::VERSION.magenta} \"#{Bridgetown::CODE_NAME.yellow}\""
puts ""
puts "Usage:"
puts " bridgetown <command> [options]"
puts ""
super
end
end
end |
This solves the problem. class MyGroup < Thor::Group
class_option :opt, aliases: :o, default: "1"
def one
puts options[:opt]
end
end
class MyCLI < Thor
register(MyGroup, "print_opt", "print_opt", "Prints the options")
tasks["print_opt"].options = MyGroup.class_options
end And running:
Will now produce this output:
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Using this toy example:
And running:
Produces this output:
The class options are not printed for this group. This appears related to this issue: #402
The text was updated successfully, but these errors were encountered: