Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions lib/cli/kit/command_help.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
16 changes: 15 additions & 1 deletion test/cli/kit/command_help_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down