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 +4 -4
- data/lib/dencli/cmd.rb +10 -7
- data/lib/dencli/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8471e357d36b81e36d1ab99ecdf91ccd0b074e851b3ba8e85d84450943e2b476
|
4
|
+
data.tar.gz: 04ed6b6810e16454b08e33e3006a7688ab4a63ce398a5acb7098918ea767bb58
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
18
|
-
|
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
|
data/lib/dencli/version.rb
CHANGED