dencli 0.5.1 → 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5f6fa7e69d426f92f554f31e17adc226687c6851b53f11750fe2887e856d7e99
4
- data.tar.gz: 9e2b3b52bed172e5a3b17f8556bb5bc90a4fa613bc631d6ccf3eff5a7e6bcbdb
3
+ metadata.gz: 8471e357d36b81e36d1ab99ecdf91ccd0b074e851b3ba8e85d84450943e2b476
4
+ data.tar.gz: 04ed6b6810e16454b08e33e3006a7688ab4a63ce398a5acb7098918ea767bb58
5
5
  SHA512:
6
- metadata.gz: 3e8c379293addfafee9b688c1eb02c336616ce1e66522bb98d94966eacf3e5fa1a23f5e7df1de6f731d97700fd44ea1188f0f8e8f30e6729459799254348bf5f
7
- data.tar.gz: ae7fe49dd995e7fd186fa7f52c4c9f85f4e35c5b70fc6f3e11a59082cb395ae50bab87e455475241e39048a2c559fe2336a4fad8809434577c117c3565efcaff
6
+ metadata.gz: 6a753968bd74a46255be188e1f75097d14962df24affdba2581cf01c3aeaefe37fe917dd1bbb7ea658ced37dd2f4f469223f3661d0e02d604cab6790026f08d7
7
+ data.tar.gz: d5790f9ac588beb6c7fb64a223634cff15ee6b686f549923d265a875533a5ff881ed4c0130895db1216d53906b2c30e8e8fc434326dd8467d1d1745b14207944
data/lib/dencli/cmd.rb CHANGED
@@ -7,6 +7,12 @@ class DenCli::CMD
7
7
  def initialize parent, name, description, exe
8
8
  raise "Proc expected, instead of: #{exe.inspect}" unless Proc === exe
9
9
  @parent, @name, @description, @exe = parent, name, description, lambda( &exe)
10
+ @parameters = @exe.parameters
11
+ @arguments_required = @exe.parameters.select {|e| :req == e[0] }.map {|e| e[1] }
12
+ @arguments_additional = @exe.parameters.select {|e| :opt == e[0] }.map {|e| e[1] }
13
+ @arguments = @exe.parameters.select {|e| :req == e[0] or :opt == e[0] }.map {|e| e[1] }
14
+ @options_required = @exe.parameters.select {|e| :keyreq == e[0] }.map {|e| e[1] }
15
+ @options_additional = @exe.parameters.select {|e| :key == e[0] }.map {|e| e[1] }
10
16
  @options = {}
11
17
  completion {|*a| [] }
12
18
  end
@@ -14,14 +20,11 @@ class DenCli::CMD
14
20
  def _full_cmd( post) parent._full_cmd [@name]+post end
15
21
  def full_cmd() _full_cmd [] end
16
22
 
17
- def parameters() @exe.parameters end
18
- def arguments_required() @exe.parameters.select {|e| :req == e[0] }.map {|e| e[1] } end
23
+ attr_reader :parameters,
24
+ :arguments_required, :arguments_additional, :arguments,
25
+ :options_required, :options_additional
19
26
  alias required arguments_required
20
- def arguments_additional() @exe.parameters.select {|e| :opt == e[0] }.map {|e| e[1] } end
21
27
  alias additional arguments_additional
22
- def arguments() @exe.parameters.select {|e| :req == e[0] or :opt == e[0] }.map {|e| e[1] } end
23
- def options_required() @exe.parameters.select {|e| :keyreq == e[0] }.map {|e| e[1] } end
24
- def options_additional() @exe.parameters.select {|e| :key == e[0] }.map {|e| e[1] } end
25
28
 
26
29
  def complete *pre, str
27
30
  @completion.call *pre, str
@@ -54,7 +57,7 @@ class DenCli::CMD
54
57
  end
55
58
  kr = @options.select {|_, o| o.required? and not os.has_key? o.name }
56
59
  unless kr.empty?
57
- raise DenCli::UsageError, "Missing argument(s): #{kr.map {|o| o.long || o.short }.join ', '}"
60
+ raise DenCli::UsageError, "Missing argument(s): #{kr.map {|_, o| o.long || o.short }.join ', '}"
58
61
  end
59
62
  end
60
63
  @exe.call *as, **os
@@ -1,3 +1,3 @@
1
1
  class DenCli
2
- VERSION = '0.5.1'
2
+ VERSION = '0.5.2'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dencli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Denis Knauf