lib/cl/help/cmd.rb in cl-0.1.3 vs lib/cl/help/cmd.rb in cl-0.1.4
- old
+ new
@@ -2,10 +2,12 @@
require 'cl/help/usage'
class Cl
class Help
class Cmd
+ include Regex
+
attr_reader :cmd
def initialize(cmd)
@cmd = cmd
end
@@ -98,11 +100,11 @@
def format_opt(opt)
opts = []
opts << "alias: #{format_aliases(opt)}" if opt.aliases?
opts << "requires: #{opt.requires.join(', ')}" if opt.requires?
opts << "default: #{format_default(opt)}" if opt.default?
- opts << "known values: #{opt.enum.join(', ')}" if opt.enum?
+ opts << "known values: #{format_enum(opt)}" if opt.enum?
opts << "format: #{opt.format}" if opt.format?
opts << "downcase: true" if opt.downcase?
opts << "max: #{opt.max}" if opt.max?
opts << "e.g.: #{opt.example}" if opt.example?
opts << "see: #{opt.see}" if opt.see?
@@ -116,9 +118,12 @@
strs << "(deprecated, please use #{opt.name})" if opt.deprecated[0] == name
strs.join(' ')
end.join(', ')
end
+ def format_enum(opt)
+ opt.enum.map { |value| format_regex(value) }.join(', ')
+ end
def format_type(obj)
return obj.type unless obj.is_a?(Opt) && obj.type == :array
"array (string, can be given multiple times)"
end