lib/sickle.rb in sickle-0.2.0 vs lib/sickle.rb in sickle-0.3.0

- old
+ new

@@ -75,20 +75,24 @@ end end def register(parser, results) if @type == :boolean - parser.on("--#{@name}", opts[:desc]) do + parser.on("--#{cli_name}", opts[:desc]) do results[@name] = true end else - parser.on("--#{@name} #{@name.upcase}") do |v| + parser.on("--#{cli_name} #{@name.upcase}") do |v| results[@name] = coerce(v) end end end + def cli_name + @name.to_s.tr("_", "-") + end + def coerce(value) case @default when Fixnum value.to_i when Float @@ -172,10 +176,10 @@ end end end def __display_option(opt) - " --#{opt.name} (default: #{opt.default})" + " --#{opt.cli_name} (default: #{opt.default})" end end module ClassMethods def included(base)