You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#!/usr/bin/env ruby
require "thor"
require "thor/group"
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")
end
MyCLI.start
And running:
bundle exec broken_class_options.rb help print_opt
Produces this output:
Usage:
broken_class_options.rb print_opt
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:
I came up with a workaround to this by overriding the help method in my top-level Thor class. It also outputs a nice overview if no commands are provided.
Here's a abbreviated example:
classBase < Thorregister(BuildThor,"build","build","Build your site")register(ServeThor,"serve","serve","Serve your site locally")desc"help <command>","Show detailed command usage information and exit"defhelp(subcommand=nil)ifsubcommand && respond_to?(subcommand)klass=Kernel.const_get("Bridgetown::Commands::#{subcommand.capitalize}Thor")klass.start(["-h"])elseputs"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""superendendend
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: