optparse-simple 0.2.10 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/optparse-simple.rb +8 -1
- metadata +1 -1
data/lib/optparse-simple.rb
CHANGED
@@ -62,7 +62,14 @@ class OptParseSimple
|
|
62
62
|
|
63
63
|
a1 = []
|
64
64
|
a1 = options_match(@options[0], args).flatten.each_slice(2).map {|x| x if x[0]}.compact unless @options.empty?
|
65
|
-
options_remaining = XPath.match(@doc.root, 'records/option/summary[switch=""]/name/text()')
|
65
|
+
options_remaining = XPath.match(@doc.root, 'records/option/summary[switch=""]/name/text()').map(&:to_s)
|
66
|
+
mandatory_remaining = XPath.match(@doc.root, 'records/option/summary[switch="" and mandatory="true"]/name/text()').map(&:to_s)
|
67
|
+
if mandatory_remaining.length > args.length then
|
68
|
+
missing_arg = (mandatory_remaining - args).first
|
69
|
+
option = XPath.first(@doc.root, "records/option[summary/name='#{missing_arg}']")
|
70
|
+
raise option.text('records/error/summary/msg')
|
71
|
+
end
|
72
|
+
|
66
73
|
a2 = args.zip(options_remaining).map(&:reverse)
|
67
74
|
if a2.map(&:first).all? then
|
68
75
|
@h = Hash[*(a1+a2).map{|x,y| [x.to_s.to_sym, y]}.flatten]
|