cl 0.1.11 → 0.1.12

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 459af9c55e8066873b1a97420815bbc9cae92e3c
4
- data.tar.gz: b987cc5e208df1187ec06ed7a61533b8b259b153
3
+ metadata.gz: 9a4e37103d294db33627a373c3d1d19b2113b0a6
4
+ data.tar.gz: 7733d1f9d8f3ca199fcea0a697e679829e758597
5
5
  SHA512:
6
- metadata.gz: a1f965ab46d4feea6ce314874bea451b408492fdd44ae235d27104b436221591bb0504c2c9e7e4c3ac2efa78a8e5536f107278c656dd018359f2748c31cd5cd5
7
- data.tar.gz: 2f24437e9ff8e604815edc4e091c996096811618f03ebfffd7b401ee77cbb58c8d821dffd4efdcf284eb6424c08701143ff47b1392039b6f35d7307674245f59
6
+ metadata.gz: bd906f7c16c3ea0fed71806baf8c12b0e78f62ebaa8f61ea398223d51383b22075bbbfa5afa87a95e549469fad46af93e231551cc01d12207379fda5ff4d55d8
7
+ data.tar.gz: 26459916c941da8486acc6f92e87c89f91f03b37115b83149fb231843738c4eb03968c0c4b27737b8a9b525e0e7f51df6bfe21f989385622bb9bc3e3d8be002b
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cl (0.1.9)
4
+ cl (0.1.11)
5
5
  regstry (~> 1.0.3)
6
6
 
7
7
  GEM
@@ -31,18 +31,21 @@ class Cl
31
31
 
32
32
  private
33
33
 
34
+ # stopping at any arg that starts with a dash, find the command
35
+ # with the key matching the most args when joined with ":", and
36
+ # remove these used args from the array
34
37
  def lookup(args)
35
- keys = expand(args)
36
- keys = keys & Cmd.registry.keys.map(&:to_s)
37
- cmd = Cmd[keys.last] || abort("Unknown command: #{args.join(' ')}")
38
- args = args[keys.last.split(':').size..-1]
39
- [cmd, args]
40
- end
38
+ keys = args.take_while { |key| !key.start_with?('-') }
41
39
 
42
- def expand(args)
43
- keys = args.take_while { |str| !str.start_with?('-') }
44
- args = args[keys.size..-1]
45
- keys.inject([]) { |strs, str| strs << [strs.last, str].compact.join(':') }
40
+ keys = keys.inject([[], []]) do |keys, key|
41
+ keys[1] << key
42
+ keys[0] << [Cmd[keys[1].join(':')], keys[1].dup] if Cmd.registered?(keys[1].join(':'))
43
+ keys
44
+ end
45
+
46
+ cmd, keys = keys[0].last
47
+ keys.each { |key| args.delete_at(args.index(key)) }
48
+ [cmd, args]
46
49
  end
47
50
  end
48
51
  end
data/lib/cl/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  class Cl
2
- VERSION = '0.1.11'
2
+ VERSION = '0.1.12'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.11
4
+ version: 0.1.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sven Fuchs
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-05-16 00:00:00.000000000 Z
11
+ date: 2019-05-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: regstry