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 +4 -4
- data/lib/baf/cli.rb +2 -1
- data/lib/baf/option.rb +9 -4
- data/lib/baf/options_registrant.rb +2 -2
- data/lib/baf/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 01b4cd603a0c8b5fb882a9c1aa6db847a5226708
|
4
|
+
data.tar.gz: 397fd86453ebc4f2be6896aefb8bbb91a20496e1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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:
|
51
|
-
desc:
|
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