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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8471e357d36b81e36d1ab99ecdf91ccd0b074e851b3ba8e85d84450943e2b476
4
- data.tar.gz: 04ed6b6810e16454b08e33e3006a7688ab4a63ce398a5acb7098918ea767bb58
3
+ metadata.gz: b51686dc165e8a0fa5dad00dea71e56a4007be3ad050de0e7a73b3f7587baefa
4
+ data.tar.gz: 97ce2e6f4bb16974e8b1375133fbcbf8be7b1d4f15491935ebcda55557b3784f
5
5
  SHA512:
6
- metadata.gz: 6a753968bd74a46255be188e1f75097d14962df24affdba2581cf01c3aeaefe37fe917dd1bbb7ea658ced37dd2f4f469223f3661d0e02d604cab6790026f08d7
7
- data.tar.gz: d5790f9ac588beb6c7fb64a223634cff15ee6b686f549923d265a875533a5ff881ed4c0130895db1216d53906b2c30e8e8fc434326dd8467d1d1745b14207944
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, '-d=ForD', "Option d", default: "something").
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(-[^=-]+)=(.+)\z/
164
+ when /\A(-[^=-])=?(.+)\z/
165
165
  @short, @val = $1, $2 || @val
166
- when /\A(-[^=-]+)\z/
166
+ when /\A(-[^=-])\z/
167
167
  @short, @val = $1, nil
168
168
  else
169
169
  raise ArgumentError, "Unexpected format for option: #{opt.inspect}"
@@ -1,3 +1,3 @@
1
1
  class DenCli
2
- VERSION = '0.5.2'
2
+ VERSION = '0.5.3'
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.2
4
+ version: 0.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Denis Knauf