claide 0.8.2 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/claide.rb +1 -1
- data/lib/claide/argv.rb +31 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2a8ca664bd027e9572a68e5605f03e463d943908
|
4
|
+
data.tar.gz: 36dcbc3f7f3131795f1c453fe7d208a0f50a7c1c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8fb570e06b2ea203f3215e29cb822cbc2aff8a0fbfe9b1cec9765c8bb6b63fe515af7ba4a38fad57768d72ef2efaefdaedb8b5b94262cd9a473501bea9c4d19c
|
7
|
+
data.tar.gz: 8ece92f993984810f70694409feb1c2e2026038cc3b858f0587267cbc05329a606c29976fbb140c89822ece87367faa9c4d6fc5ed655c5f4ad1a7cd2055110bf
|
data/lib/claide.rb
CHANGED
data/lib/claide/argv.rb
CHANGED
@@ -184,6 +184,31 @@ module CLAide
|
|
184
184
|
delete_entry(:option, name, default)
|
185
185
|
end
|
186
186
|
|
187
|
+
# @return [Array<String>] Returns an array of all the values of the option
|
188
|
+
# with the specified `name` among the remaining
|
189
|
+
# parameters.
|
190
|
+
#
|
191
|
+
# @param [String] name
|
192
|
+
# The name of the option to look for among the remaining
|
193
|
+
# parameters.
|
194
|
+
#
|
195
|
+
# @note This will remove the option from the remaining parameters.
|
196
|
+
#
|
197
|
+
# @example
|
198
|
+
#
|
199
|
+
# argv = CLAide::ARGV.new(['--ignore=foo', '--ignore=bar'])
|
200
|
+
# argv.all_options('include') # => []
|
201
|
+
# argv.all_options('ignore') # => ['bar', 'foo']
|
202
|
+
# argv.remainder # => []
|
203
|
+
#
|
204
|
+
def all_options(name)
|
205
|
+
options = []
|
206
|
+
while entry = option(name)
|
207
|
+
options << entry
|
208
|
+
end
|
209
|
+
options
|
210
|
+
end
|
211
|
+
|
187
212
|
private
|
188
213
|
|
189
214
|
# @return [Array<Array<Symbol, String, Array>>] A list of tuples for each
|
@@ -207,13 +232,14 @@ module CLAide
|
|
207
232
|
#
|
208
233
|
def delete_entry(requested_type, requested_key, default)
|
209
234
|
result = nil
|
210
|
-
@entries.
|
235
|
+
entry = @entries.reverse_each.find do |type, (key, value)|
|
211
236
|
if requested_key == key && requested_type == type
|
212
237
|
result = value
|
213
238
|
true
|
214
239
|
end
|
215
240
|
end
|
216
|
-
|
241
|
+
@entries.delete(entry) if entry
|
242
|
+
entry.nil? ? default : result
|
217
243
|
end
|
218
244
|
|
219
245
|
module Parser
|
@@ -231,8 +257,10 @@ module CLAide
|
|
231
257
|
def self.parse(argv)
|
232
258
|
entries = []
|
233
259
|
copy = argv.map(&:to_s)
|
260
|
+
double_dash = false
|
234
261
|
while argument = copy.shift
|
235
|
-
|
262
|
+
next if !double_dash && double_dash = (argument == '--')
|
263
|
+
type = double_dash ? :arg : argument_type(argument)
|
236
264
|
parsed_argument = parse_argument(type, argument)
|
237
265
|
entries << [type, parsed_argument]
|
238
266
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: claide
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eloy Duran
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-07-02 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description:
|
15
15
|
email:
|