optparse-simple 0.2.10 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. data/lib/optparse-simple.rb +8 -1
  2. metadata +1 -1
@@ -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]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: optparse-simple
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.10
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors: []
7
7