lib/cl/cmd.rb in cl-1.1.2 vs lib/cl/cmd.rb in cl-1.1.3

- old
+ new

@@ -15,11 +15,11 @@ class Cmd include Registry extend Dsl class << self - include Merge, Underscore + include Merge, Suggest, Underscore inherited = ->(const) do const.register [registry_key, underscore(const.name.split('::').last)].compact.join(':') if const.name const.define_singleton_method(:inherited, &inherited) end @@ -32,9 +32,13 @@ def parse(ctx, cmd, args) parser = Parser.new(cmd, args) args, opts = parser.args, parser.opts unless self == Help opts = merge(ctx.config[registry_key], opts) if ctx.config[registry_key] [args, opts || {}] + end + + def suggestions(opt) + suggest(opts.map(&:name), opt.sub(/^--/, '')) end end opt '--help', 'Get help on this command'