lib/cl/cmd.rb in cl-1.1.5 vs lib/cl/cmd.rb in cl-1.2.0
- old
+ new
@@ -21,18 +21,18 @@
inherited = ->(const) do
if const.name
key = underscore(const.name.split('::').last)
key = [registry_key, key].compact.join(':') unless abstract?
+ const.register(key)
end
- const.register key
const.define_singleton_method(:inherited, &inherited)
end
define_method(:inherited, &inherited)
def cmds
- registry.values
+ registry.values.uniq
end
def parse(ctx, cmd, args)
parser = Parser.new(cmd, args)
args, opts = parser.args, parser.opts unless self == Help
@@ -53,10 +53,10 @@
def initialize(ctx, args)
@ctx = ctx
args, opts = self.class.parse(ctx, self, args)
@opts = self.class.opts.apply(self, self.opts.merge(opts))
- @args = self.class.args.apply(self, args, opts)
+ @args = self.class.args.apply(self, args, opts) unless help? && !is_a?(Help)
end
def opts
@opts ||= {}
end