diff --git a/lib/cli/kit/command_help.rb b/lib/cli/kit/command_help.rb index 3fa25eb..4c9a80f 100644 --- a/lib/cli/kit/command_help.rb +++ b/lib/cli/kit/command_help.rb @@ -134,14 +134,6 @@ def build_options opts = opts_class return unless opts - methods = [] - loop do - methods.concat(opts.public_instance_methods(false)) - break if opts.superclass == CLI::Kit::Opts - - opts = opts.superclass - end - @defn = Args::Definition.new o = opts.new o.define!(@defn) diff --git a/test/cli/kit/command_help_test.rb b/test/cli/kit/command_help_test.rb index a6998f4..a08d6a2 100644 --- a/test/cli/kit/command_help_test.rb +++ b/test/cli/kit/command_help_test.rb @@ -19,7 +19,20 @@ class ACommand < CLI::Kit::BaseCommand example('-q -u neato', "quietly do a thing with 'neato'") - class Opts < CLI::Kit::Opts + class BaseOpts < CLI::Kit::Opts + class << self + def inherited(subclass) + super + subclass.class_eval do + def dry_run + flag(short: '-d', desc: 'dry run') + end + end + end + end + end + + class Opts < BaseOpts def quiet flag(short: '-q', desc: 'be quiet') end @@ -47,6 +60,7 @@ def test_a \e[0;36mtest a-command\e[0m -q -u neato \e[0;3;38;5;244m# quietly do a thing with 'neato'\e[0m \e[0;1mOptions:\e[0m + -d \e[0;3;38;5;244m# dry run\e[0m -h, --help \e[0;3;38;5;244m# Show this help message\e[0m -l, --loud \e[0;3;38;5;244m# be loud\e[0m -q \e[0;3;38;5;244m# be quiet\e[0m