claide 0.8.2 → 0.9.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 (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/claide.rb +1 -1
  3. data/lib/claide/argv.rb +31 -3
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7156facd276a37e3ea6472d696a26731707068fc
4
- data.tar.gz: f4d4afb23eaaf49a93345fc0f4cf3afdc5347248
3
+ metadata.gz: 2a8ca664bd027e9572a68e5605f03e463d943908
4
+ data.tar.gz: 36dcbc3f7f3131795f1c453fe7d208a0f50a7c1c
5
5
  SHA512:
6
- metadata.gz: ee6f3f61074791bb401abf6ab065071425e169d17daad152361b637a631e02b0c4fa48ce7ce296c22d787c8f189cbb425346f9541921a221dde4dc30b4c8934c
7
- data.tar.gz: 70e07c305f148c494760417f67277d4d99e1885c763fae4ca76e296e68ec476af31a15fb7462ad2e47ecaa2366a4662aeebc60c9116c1369497cc533c2b98347
6
+ metadata.gz: 8fb570e06b2ea203f3215e29cb822cbc2aff8a0fbfe9b1cec9765c8bb6b63fe515af7ba4a38fad57768d72ef2efaefdaedb8b5b94262cd9a473501bea9c4d19c
7
+ data.tar.gz: 8ece92f993984810f70694409feb1c2e2026038cc3b858f0587267cbc05329a606c29976fbb140c89822ece87367faa9c4d6fc5ed655c5f4ad1a7cd2055110bf
data/lib/claide.rb CHANGED
@@ -8,7 +8,7 @@ module CLAide
8
8
  #
9
9
  # CLAide’s version, following [semver](http://semver.org).
10
10
  #
11
- VERSION = '0.8.2'
11
+ VERSION = '0.9.0'
12
12
 
13
13
  require 'claide/ansi'
14
14
  require 'claide/argument'
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.delete_if do |type, (key, value)|
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
- result.nil? ? default : result
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
- type = argument_type(argument)
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.8.2
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-06-27 00:00:00.000000000 Z
12
+ date: 2015-07-02 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description:
15
15
  email: