lib/gli/command_line_token.rb in gli-1.1.3 vs lib/gli/command_line_token.rb in gli-1.2.0
- old
+ new
@@ -32,12 +32,16 @@
# Handles dealing with the "names" param, parsing
# it into the primary name and aliases list
def parse_names(names)
+ # Allow strings; convert to symbols
+ names = [names].flatten.map(&:to_sym)
names_hash = Hash.new
- names = names.is_a?(Array) ? names : [names]
- names.each { |n| names_hash[self.class.name_as_string(n)] = true }
+ names.each do |n|
+ raise ArgumentError.new("#{n} has spaces; they are not allowed") if n.to_s =~ /\s/
+ names_hash[self.class.name_as_string(n)] = true
+ end
name = names.shift
aliases = names.length > 0 ? names : nil
[name,aliases,names_hash]
end