baf 0.5.0 → 0.6.0

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
  SHA1:
3
- metadata.gz: 7091d7bfbb0d1d56888a9210f7585e8f6b5d3cac
4
- data.tar.gz: ef092a44d2b3596f9814c19250f087430ff172b9
3
+ metadata.gz: 01b4cd603a0c8b5fb882a9c1aa6db847a5226708
4
+ data.tar.gz: 397fd86453ebc4f2be6896aefb8bbb91a20496e1
5
5
  SHA512:
6
- metadata.gz: 69f39a7ff0f4bf2e05d184bc5e3c840a0eb8edd9e86b00f74f310a82ff94b5089935a16e81b17a8b90364f17762c0bd7a98d6241cb0ac3656b986853734f8096
7
- data.tar.gz: 319caad20f725d0baf5b67dec5cb19d723403a33aa10b85af647a57f57d64ef225b5ff90ead9bb8d66000fe32ed07ef69aaa42c022612a86f105e8c5f1b1c415
6
+ metadata.gz: 5a6ad3ff49957f133084b215f325868bab5ffae69c8f5cadb87ec57d83e84eb23b7b6ad02a3b806e122b25497dcae0e20d4d2c50137d7e7cbce3e6968f96932e
7
+ data.tar.gz: 3350cccfc0f5e1c2afa5c5958e840acc54c9b4b52a8145c39cbdb5d2322d8009c5f532e4117a07c12f9f130edb87a66fa975bf72aa3fade3ff398b2006ec93b4
data/lib/baf/cli.rb CHANGED
@@ -63,11 +63,12 @@ module Baf
63
63
  end
64
64
 
65
65
  def flag_version version
66
- flag :V, :version, 'print version', -> env { env.puts version },
66
+ flag :V, :version, 'print version', -> *, env { env.puts version },
67
67
  tail: true
68
68
  end
69
69
 
70
70
  def option *args
71
+ args = [*args, Proc.new] if block_given?
71
72
  registrant.option *args
72
73
  end
73
74
 
data/lib/baf/option.rb CHANGED
@@ -29,13 +29,17 @@ module Baf
29
29
 
30
30
  def to_parser_arguments env
31
31
  message = tail? ? PARSER_MESSAGE_TAIL : PARSER_MESSAGE
32
- mblock = block ? -> * { block[env] } : parser_argument_block(env)
32
+ mblock = if block?
33
+ -> *args { block[*args, env] }
34
+ else
35
+ parser_argument_block env
36
+ end
33
37
  [message, "-#{short}", parser_argument_long, parser_argument_desc, mblock]
34
38
  end
35
39
 
36
40
  private
37
41
 
38
- def build_attrs short, long, arg_or_desc = nil, desc_or_block = nil
42
+ def build_attrs short, long, arg_or_desc = nil, desc_or_block = nil, block = nil
39
43
  {
40
44
  short: short,
41
45
  long: long
@@ -47,8 +51,9 @@ module Baf
47
51
  }
48
52
  when String
49
53
  {
50
- arg: arg_or_desc,
51
- desc: desc_or_block
54
+ arg: arg_or_desc,
55
+ desc: desc_or_block,
56
+ block: block
52
57
  }
53
58
  else
54
59
  {}
@@ -26,9 +26,9 @@ module Baf
26
26
  yield if block_given?
27
27
  parser.separator SUMMARY_HEADER
28
28
  options_tail, options_standard = options.partition &:tail?
29
- options_standard.each { |opt|register_option env, parser, opt }
29
+ options_standard.each { |opt| register_option env, parser, opt }
30
30
  register_default_options env, parser
31
- options_tail.each { |opt|register_option env, parser, opt }
31
+ options_tail.each { |opt| register_option env, parser, opt }
32
32
  end
33
33
 
34
34
  private
data/lib/baf/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Baf
2
- VERSION = '0.5.0'.freeze
2
+ VERSION = '0.6.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: baf
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thibault Jouan