dencli 0.5.2 → 0.5.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/example.rb +5 -3
- data/lib/dencli/cmd.rb +3 -3
- 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: b51686dc165e8a0fa5dad00dea71e56a4007be3ad050de0e7a73b3f7587baefa
|
4
|
+
data.tar.gz: 97ce2e6f4bb16974e8b1375133fbcbf8be7b1d4f15491935ebcda55557b3784f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5a98c654de4a78a1dc07c41a8cd2dffcba9d34b57c03b80784b8d652f155d5a53f54370906ec51404c0b6df45a4e387fb8027b5938539780a50e680b9dfbd123
|
7
|
+
data.tar.gz: 3a0e657604254c35e65ae6c501af0c79fd6887b7cb45b8a4ea1693c6fd666eddf04d5e3b060841bf6b0619c35bfdd6af61e98d9598090c9101f4631d993d84ee
|
data/bin/example.rb
CHANGED
@@ -6,13 +6,15 @@ require 'dencli'
|
|
6
6
|
|
7
7
|
cli = DenCli.new :example, "This is an example for generate a DenCli-API"
|
8
8
|
cli.cmd( :args, "Expects and prints given arguments",
|
9
|
-
&lambda {|a, b, c:, d:, e:|
|
9
|
+
&lambda {|a, b, c:, d:, e:, f:, g:|
|
10
10
|
p a: a, b: b, c: c, d: d, e: e
|
11
11
|
}).
|
12
12
|
opt( :c, '-c=ForC', "Option c").
|
13
|
-
opt( :d, '-
|
13
|
+
opt( :d, '-dForD', "Option d", default: "something").
|
14
14
|
opt( :e, '-e', "Toggle e", default: false).
|
15
|
-
opt( :f, '--[no-]f', "Toggle f", default: false)
|
15
|
+
opt( :f, '--[no-]f', "Toggle f", default: false).
|
16
|
+
opt( :g, '--long-option=sth', "Long option, no short option", default: "nothing").
|
17
|
+
opt( :h, '-hsth', "No long option, only short option", default: "nothing")
|
16
18
|
|
17
19
|
cli.cmd( :example, "I have an example command") { STDERR.puts "This is an example" }
|
18
20
|
cli.cmd( :help, "", aliases: [nil, '-h', '--help'], &lambda {|*args, full:|
|
data/lib/dencli/cmd.rb
CHANGED
@@ -72,7 +72,7 @@ class DenCli::CMD
|
|
72
72
|
def _usage output
|
73
73
|
output << full_cmd.join( ' ')
|
74
74
|
@options.each do |_, o|
|
75
|
-
s = "#{o.short||o.long}#{o.val ? ?= : ''}#{o.val}"
|
75
|
+
s = "#{o.short||o.long}#{(!o.short && o.val) ? ?= : ''}#{o.val}"
|
76
76
|
output << (o.required? ? " #{s}" : " [#{s}]")
|
77
77
|
end
|
78
78
|
if @exe.lambda?
|
@@ -161,9 +161,9 @@ class DenCli::CMD
|
|
161
161
|
@long, @val = $1, $2 || @val
|
162
162
|
when /\A(--[^=]+)\z/
|
163
163
|
@long, @val = $1, nil
|
164
|
-
when /\A(-[^=-]
|
164
|
+
when /\A(-[^=-])=?(.+)\z/
|
165
165
|
@short, @val = $1, $2 || @val
|
166
|
-
when /\A(-[^=-]
|
166
|
+
when /\A(-[^=-])\z/
|
167
167
|
@short, @val = $1, nil
|
168
168
|
else
|
169
169
|
raise ArgumentError, "Unexpected format for option: #{opt.inspect}"
|
data/lib/dencli/version.rb
CHANGED