lib/gli/option_parser_factory.rb in gli-2.6.0 vs lib/gli/option_parser_factory.rb in gli-2.6.1

- old
+ new

@@ -35,12 +35,16 @@ end private def set_defaults(options_by_name,options_hash) - options_by_name.each do |name,option| - options_hash[name] = option.default_value if options_hash[name].nil? + options_by_name.values.each do |option| + option.names_and_aliases.each do |option_name| + [option_name,option_name.to_sym].each do |name| + options_hash[name] = option.default_value if options_hash[name].nil? + end + end end end def self.setup_accepts(opts,accepts) accepts.each do |object,block| @@ -51,10 +55,10 @@ end def self.setup_options(opts,tokens,options) tokens.each do |ignore,token| opts.on(*token.arguments_for_option_parser) do |arg| - [token.name,token.aliases].flatten.compact.map(&:to_s).each do |name| + token.names_and_aliases.each do |name| options[name] = arg options[name.to_sym] = arg end end end