arg-parser 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- M2JiZDNjZTA3NTZiNWE0ZmE2ZDI5M2VkMzY4NjEwZWEwMWMxMDRiNg==
4
+ ODcwNmFlYTFmYzRkMDE2NzRkYzVjMmIyZjEzOGZiMDZmNWYxODRjNQ==
5
5
  data.tar.gz: !binary |-
6
- N2QwNjcyMWE5MzQ2MTk4MDFmNmFmZGZiNjk4ZTFiMmJiODY5ZWFmNg==
6
+ NzNlZjg3MmI1YTVkNjY1NmNmOThhYWIyM2I3YjJmMzgzZDgzMTViZg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZjIxZWEzM2ZlNzdiMmZlODBmYWMwYzI3ODQ2MTA3NWVhYjEwZjBhYTFjNzkz
10
- MDNhZDA5YmQzMTM4ODg4MmE2YzUyYjBmNjNmNTZiZWJiNWU2ZmViZWQ2MjJl
11
- OTAyYjg2Njg5ZTIzZTQ3ZGM3MTg4YzM3ZjZjYzVmNGIxNzRhY2I=
9
+ ZmY0MThmOTJiM2UwNmVlODEwZWFkNjczNWZlNmYwNzA4NThkNGMwOGNkYTdj
10
+ OWNlY2ZlZGVlYzMwNTNhMDM2OTJhM2RmNDIzOTFhZmVmNzdhOTBiZmY4M2Qw
11
+ N2I5YjdiNjhhNDdlYWI4ZjJiNTNmYzM3YjM1ZDJiZTYzMGM3NWU=
12
12
  data.tar.gz: !binary |-
13
- MjgyMmQxMmRmMjViN2YyNWJmMGY5MTIzZDIyYTk0MzQ0N2MzYzkwYzY5NTJj
14
- NmExMzE4Yjg4ODkxZGUyMDZmODUyYWIzZGFhYjUxZTBjNGRiYzJhMTNjNDAz
15
- MGZjNTExNGU2MTJjZjIwODgzOTAyZTBjY2IxMzI1Yjc2MWVmZTY=
13
+ ZWNlNThjZGRiZGM3YjY4ZGQ2N2FkODFiN2E4YzMyMGRkNDY2MDhmMzRkNGJl
14
+ NTNkMzZkMzU0Y2ZkN2VkMmM3YjBhMWU5MDI0ZDE1YTBiN2JiNzIzYzQ1MmYz
15
+ MDhmYTk0NjYwMzI4ODU4MWY4NDU0ODJlMDgxMzZmZTU3YjE5NWY=
@@ -57,7 +57,7 @@ module ArgParser
57
57
  if arg.short_key && @short_keys[arg.short_key]
58
58
  raise ArgumentError, "An argument with short key '#{arg.short_key}' has already been defined"
59
59
  end
60
- if rest_args
60
+ if arg.is_a?(RestArgument) && rest_args
61
61
  raise ArgumentError, "Only one rest argument can be defined"
62
62
  end
63
63
  @arguments[arg.key] = arg
@@ -175,7 +175,7 @@ module ArgParser
175
175
  errors = []
176
176
  @require_set.each do |req, sets|
177
177
  sets.each do |set|
178
- count = set.count{ |arg| args.has_key?(arg.key) }
178
+ count = set.count{ |arg| args.has_key?(arg.key) && args[arg.key] }
179
179
  case req
180
180
  when :one
181
181
  if count == 0
@@ -132,7 +132,7 @@ module ArgParser
132
132
  # include this module. Uses the +args_def+ argument definition stored on
133
133
  # on the class to define the arguments to parse.
134
134
  def parse_arguments(args = ARGV)
135
- args_def.parse(args)
135
+ args_def.parse(args)
136
136
  end
137
137
 
138
138
 
@@ -165,6 +165,8 @@ module ArgParser
165
165
  self.errors.concat(@definition.validate_requirements(result))
166
166
  if self.errors.size > 0
167
167
  @show_usage = true
168
+ elsif result.empty?
169
+ BasicObject.new
168
170
  else
169
171
  props = result.keys
170
172
  @definition.args.each{ |arg| props << arg.key unless result.has_key?(arg.key) }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: arg-parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Gardiner