benry-cmdopt 2.0.2 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGES.md +8 -0
- data/README.md +37 -12
- data/benry-cmdopt.gemspec +1 -1
- data/doc/benry-cmdopt.html +35 -11
- data/lib/benry/cmdopt.rb +36 -12
- data/test/cmdopt_test.rb +67 -10
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5e37b3eb5a8294bfae3627f384720f843e2c6ae9c79ec0cc704b732368d46437
|
4
|
+
data.tar.gz: 3a3b34226485ae5c0aaa3f3b90d6ba281b34f7843d5e03179235784af0fc2467
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f1aae8384f952ddbc0ba5408e39e5b289d09c9b9e768a4cee237c723d7f0bef459b2ab7c8e3639705e8495790fb02bb6fced99bf9a3676e772d4b0c2d622961d
|
7
|
+
data.tar.gz: 737074f681fa450d2e0fc9b82b85aedba8088db313b522c32b1c01cae6a68ed091da08ca437f58e543b0a6d896618c42a078ded25bba9fba971c3e3ec90bc82f
|
data/CHANGES.md
CHANGED
@@ -2,6 +2,14 @@ CHANGES
|
|
2
2
|
=======
|
3
3
|
|
4
4
|
|
5
|
+
Release 2.1.0 (2023-10-15)
|
6
|
+
--------------------------
|
7
|
+
|
8
|
+
* [enhance] Add `hidden: true` keyword argument to `Benry::Schema#add()` and `Benry::Facade#add()`. This keyword argument makes the option as hidden option.
|
9
|
+
* [change] Option which name stars with '_' is now not regarded as hidden option. Use `hidden: true` instead.
|
10
|
+
* [enhance] Add `important: (true|false)` keyword argument to `Benry::Schema#add()` and `Benry::Facade#add()`. This keyword argument makes help message of the option printed in decorated format.
|
11
|
+
|
12
|
+
|
5
13
|
Release 2.0.2 (2023-10-12)
|
6
14
|
--------------------------
|
7
15
|
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Benry-CmdOpt
|
2
2
|
|
3
|
-
($Release: 2.0
|
3
|
+
($Release: 2.1.0 $)
|
4
4
|
|
5
5
|
|
6
6
|
|
@@ -38,6 +38,7 @@ Benry-CmdOpt requires Ruby >= 2.3.
|
|
38
38
|
* [Global Options with Sub-Commands](#global-options-with-sub-commands)
|
39
39
|
* [Detailed Description of Option](#detailed-description-of-option)
|
40
40
|
* [Option Tag](#option-tag)
|
41
|
+
* [Important Options](#important-options)
|
41
42
|
* [Not Supported](#not-supported)
|
42
43
|
* [Internal Classes](#internal-classes)
|
43
44
|
* [License and Copyright](#license-and-copyright)
|
@@ -470,22 +471,20 @@ p options #=> {:lib=>["foo", "bar", "baz"]}
|
|
470
471
|
|
471
472
|
Benry-CmdOpt regards the following options as hidden.
|
472
473
|
|
473
|
-
*
|
474
|
+
* Keyword argument `hidden: true` is passed to `.add()` method.
|
474
475
|
* Or description is nil.
|
475
476
|
|
476
|
-
|
477
|
-
|
478
|
-
These hidden options are not included in help message.
|
477
|
+
Hidden options are not included in help message.
|
479
478
|
|
480
479
|
```ruby
|
481
480
|
require 'benry/cmdopt'
|
482
481
|
cmdopt = Benry::CmdOpt.new
|
483
|
-
cmdopt.add(:help
|
484
|
-
cmdopt.add(:
|
485
|
-
cmdopt.add(:
|
482
|
+
cmdopt.add(:help , '-h', "help message")
|
483
|
+
cmdopt.add(:logging, '-L', "logging", hidden: true) # hidden
|
484
|
+
cmdopt.add(:debug , '-D', nil) # hidden (desc is nil)
|
486
485
|
puts cmdopt.to_s()
|
487
486
|
|
488
|
-
### output (neither '-
|
487
|
+
### output (neither '-L' nor '-D' is shown because hidden options)
|
489
488
|
# -h : help message
|
490
489
|
```
|
491
490
|
|
@@ -497,8 +496,8 @@ puts cmdopt.to_s(all: true) # or: cmdopt.to_s(nil, all: true)
|
|
497
496
|
|
498
497
|
### output
|
499
498
|
# -h : help message
|
500
|
-
# -D :
|
501
499
|
# -L : logging
|
500
|
+
# -D :
|
502
501
|
```
|
503
502
|
|
504
503
|
|
@@ -613,11 +612,37 @@ end
|
|
613
612
|
```
|
614
613
|
|
615
614
|
|
615
|
+
### Important Options
|
616
|
+
|
617
|
+
You can specify that the option is important or not.
|
618
|
+
Pass `important: true` or `important: false` keyword argument to `#add()` method of `Benry::CmdOpt` or `Benry::CmdOpt::Schema` object.
|
619
|
+
|
620
|
+
The help message of options is decorated according to value of `important:` keyword argument.
|
621
|
+
|
622
|
+
* Printed in bold font when `important: true` specified to the option.
|
623
|
+
* Printed in gray color when `important: false` specified to the option.
|
624
|
+
|
625
|
+
```ruby
|
626
|
+
require 'benry/cmdopt'
|
627
|
+
|
628
|
+
cmdopt = Benry::CmdOpt.new()
|
629
|
+
cmdopt.add(:help , "-h", "help message")
|
630
|
+
cmdopt.add(:verbose, "-v", "verbose mode", important: true) # !!!
|
631
|
+
cmdopt.add(:debug , "-D", "debug mode" , important: false) # !!!
|
632
|
+
puts cmdopt.option_help()
|
633
|
+
|
634
|
+
## output:
|
635
|
+
# -h : help message
|
636
|
+
# -v : verbose mode # bold font
|
637
|
+
# -D : debug mode # gray color
|
638
|
+
```
|
639
|
+
|
640
|
+
|
616
641
|
### Not Supported
|
617
642
|
|
618
|
-
* default value
|
643
|
+
* default value when the option not specified in command-line
|
619
644
|
* `--no-xxx` style option
|
620
|
-
* bash/zsh completion
|
645
|
+
* bash/zsh completion (may be supported in the future)
|
621
646
|
* I18N of error message (may be supported in the future)
|
622
647
|
|
623
648
|
|
data/benry-cmdopt.gemspec
CHANGED
data/doc/benry-cmdopt.html
CHANGED
@@ -21,7 +21,7 @@
|
|
21
21
|
<ul class="nav">
|
22
22
|
</ul>
|
23
23
|
</nav>
|
24
|
-
<p>($Release: 2.0
|
24
|
+
<p>($Release: 2.1.0 $)</p>
|
25
25
|
<section class="section" id="whats-this">
|
26
26
|
<h2>What's This?</h2>
|
27
27
|
<p>Benry-CmdOpt is a command option parser library, like <code>optparse.rb</code>
|
@@ -53,6 +53,7 @@ and easy to understahnd.</p>
|
|
53
53
|
<li><a href="#global-options-with-sub-commands">Global Options with Sub-Commands</a></li>
|
54
54
|
<li><a href="#detailed-description-of-option">Detailed Description of Option</a></li>
|
55
55
|
<li><a href="#option-tag">Option Tag</a></li>
|
56
|
+
<li><a href="#important-options">Important Options</a></li>
|
56
57
|
<li><a href="#not-supported">Not Supported</a></li>
|
57
58
|
</ul></li>
|
58
59
|
<li><a href="#internal-classes">Internal Classes</a></li>
|
@@ -462,20 +463,19 @@ p options #=> <strong>{:lib=>["foo", "bar", "baz"]}</strong>
|
|
462
463
|
<h3>Hidden Option</h3>
|
463
464
|
<p>Benry-CmdOpt regards the following options as hidden.</p>
|
464
465
|
<ul>
|
465
|
-
<li>
|
466
|
+
<li>Keyword argument <code>hidden: true</code> is passed to <code>.add()</code> method.</li>
|
466
467
|
<li>Or description is nil.</li>
|
467
468
|
</ul>
|
468
|
-
<p>
|
469
|
-
<p>These hidden options are not included in help message.</p>
|
469
|
+
<p>Hidden options are not included in help message.</p>
|
470
470
|
<pre class="language-ruby">
|
471
471
|
require 'benry/cmdopt'
|
472
472
|
cmdopt = Benry::CmdOpt.new
|
473
|
-
cmdopt.add(:help
|
474
|
-
cmdopt.add(:
|
475
|
-
cmdopt.add(
|
473
|
+
cmdopt.add(:help , '-h', "help message")
|
474
|
+
cmdopt.add(:logging, '-L', "logging", <strong>hidden: true</strong>) # hidden
|
475
|
+
cmdopt.add(:debug , '-D', <strong>nil</strong>) # hidden (desc is nil)
|
476
476
|
puts cmdopt.to_s()
|
477
477
|
|
478
|
-
### output (neither '-
|
478
|
+
### output (neither '-L' nor '-D' is shown because hidden options)
|
479
479
|
# -h : help message
|
480
480
|
</pre>
|
481
481
|
<p>To show all options including hidden ones, add <code>all: true</code> to <code>cmdopt.to_s()</code>.</p>
|
@@ -485,8 +485,8 @@ puts cmdopt.to_s(<strong>all: true</strong>) # or: cmdopt.to_s(nil, all: true)
|
|
485
485
|
|
486
486
|
### output
|
487
487
|
# -h : help message
|
488
|
-
# <strong>-D :</strong>
|
489
488
|
# <strong>-L : logging</strong>
|
489
|
+
# <strong>-D : </strong>
|
490
490
|
</pre>
|
491
491
|
</section>
|
492
492
|
<section class="subsection" id="global-options-with-sub-commands">
|
@@ -591,12 +591,36 @@ end
|
|
591
591
|
#version: <strong>tag=nil</strong>
|
592
592
|
</pre>
|
593
593
|
</section>
|
594
|
+
<section class="subsection" id="important-options">
|
595
|
+
<h3>Important Options</h3>
|
596
|
+
<p>You can specify that the option is important or not.
|
597
|
+
Pass <code>important: true</code> or <code>important: false</code> keyword argument to <code>#add()</code> method of <code>Benry::CmdOpt</code> or <code>Benry::CmdOpt::Schema</code> object.</p>
|
598
|
+
<p>The help message of options is decorated according to value of <code>important:</code> keyword argument.</p>
|
599
|
+
<ul>
|
600
|
+
<li>Printed in bold font when <code>important: true</code> specified to the option.</li>
|
601
|
+
<li>Printed in gray color when <code>important: false</code> specified to the option.</li>
|
602
|
+
</ul>
|
603
|
+
<pre class="language-ruby">
|
604
|
+
require 'benry/cmdopt'
|
605
|
+
|
606
|
+
cmdopt = Benry::CmdOpt.new()
|
607
|
+
cmdopt.add(:help , "-h", "help message")
|
608
|
+
cmdopt.add(:verbose, "-v", "verbose mode", <strong>important: true</strong>) # !!!
|
609
|
+
cmdopt.add(:debug , "-D", "debug mode" , <strong>important: false</strong>) # !!!
|
610
|
+
puts cmdopt.option_help()
|
611
|
+
|
612
|
+
## output:
|
613
|
+
# -h : help message
|
614
|
+
# -v : verbose mode # bold font
|
615
|
+
# -D : debug mode # gray color
|
616
|
+
</pre>
|
617
|
+
</section>
|
594
618
|
<section class="subsection" id="not-supported">
|
595
619
|
<h3>Not Supported</h3>
|
596
620
|
<ul>
|
597
|
-
<li>default value</li>
|
621
|
+
<li>default value when the option not specified in command-line</li>
|
598
622
|
<li><code>--no-xxx</code> style option</li>
|
599
|
-
<li>bash/zsh completion</li>
|
623
|
+
<li>bash/zsh completion (may be supported in the future)</li>
|
600
624
|
<li>I18N of error message (may be supported in the future)</li>
|
601
625
|
</ul>
|
602
626
|
</section>
|
data/lib/benry/cmdopt.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
4
|
###
|
5
|
-
### $Release: 2.0
|
5
|
+
### $Release: 2.1.0 $
|
6
6
|
### $Copyright: copyright(c) 2021 kwatch@gmail.com $
|
7
7
|
### $License: MIT License $
|
8
8
|
###
|
@@ -23,7 +23,7 @@ end
|
|
23
23
|
module Benry::CmdOpt
|
24
24
|
|
25
25
|
|
26
|
-
VERSION = '$Release: 2.0
|
26
|
+
VERSION = '$Release: 2.1.0 $'.split()[1]
|
27
27
|
|
28
28
|
|
29
29
|
def self.new()
|
@@ -40,11 +40,11 @@ module Benry::CmdOpt
|
|
40
40
|
|
41
41
|
attr_reader :schema
|
42
42
|
|
43
|
-
def add(key, optdef, desc, *rest, type: nil, rexp: nil, pattern: nil, enum: nil, range: nil, value: nil, detail: nil, tag: nil, &callback)
|
43
|
+
def add(key, optdef, desc, *rest, type: nil, rexp: nil, pattern: nil, enum: nil, range: nil, value: nil, detail: nil, hidden: nil, important: nil, tag: nil, &callback)
|
44
44
|
rexp ||= pattern # for backward compatibility
|
45
45
|
#; [!vmb3r] defines command option.
|
46
46
|
#; [!71cvg] type, rexp, enum, and range are can be passed as positional args as well as keyword args.
|
47
|
-
@schema.add(key, optdef, desc, *rest, type: type, rexp: rexp, enum: enum, range: range, value: value, detail: detail, tag: tag, &callback)
|
47
|
+
@schema.add(key, optdef, desc, *rest, type: type, rexp: rexp, enum: enum, range: range, value: value, detail: detail, hidden: hidden, important: important, tag: tag, &callback)
|
48
48
|
#; [!tu4k3] returns self.
|
49
49
|
self
|
50
50
|
end
|
@@ -103,7 +103,7 @@ module Benry::CmdOpt
|
|
103
103
|
self
|
104
104
|
end
|
105
105
|
|
106
|
-
def add(key, optdef, desc, *rest, type: nil, rexp: nil, pattern: nil, enum: nil, range: nil, value: nil, detail: nil, tag: nil, &callback)
|
106
|
+
def add(key, optdef, desc, *rest, type: nil, rexp: nil, pattern: nil, enum: nil, range: nil, value: nil, detail: nil, hidden: nil, important: nil, tag: nil, &callback)
|
107
107
|
rexp ||= pattern # for backward compatibility
|
108
108
|
#; [!kuhf9] type, rexp, enum, and range are can be passed as positional args as well as keyword args.
|
109
109
|
rest.each do |x|
|
@@ -137,7 +137,7 @@ module Benry::CmdOpt
|
|
137
137
|
end
|
138
138
|
#; [!yht0v] keeps command option definitions.
|
139
139
|
item = SchemaItem.new(key, optdef, desc, short, long, param, required,
|
140
|
-
type: type, rexp: rexp, enum: enum, range: range, value: value, detail: detail, tag: tag, &callback)
|
140
|
+
type: type, rexp: rexp, enum: enum, range: range, value: value, detail: detail, hidden: hidden, important: important, tag: tag, &callback)
|
141
141
|
@items << item
|
142
142
|
item
|
143
143
|
end
|
@@ -157,10 +157,16 @@ module Benry::CmdOpt
|
|
157
157
|
#; [!to1th] includes all option help when `all` is true.
|
158
158
|
#; [!a4qe4] option should not be hidden if description is empty string.
|
159
159
|
sb = []
|
160
|
-
width = nil; indent = nil
|
161
|
-
|
162
|
-
|
160
|
+
width = nil; indent = nil; color_p = $stdout.tty?
|
161
|
+
@items.each do |item|
|
162
|
+
next if ! all && item.hidden?
|
163
|
+
#; [!jrwb6] decorates help message according to `important:` value of option.
|
164
|
+
#; [!9nlfb] not decorate help message when stdout is not a tty.
|
165
|
+
s = format % [item.optdef, item.desc || ""]
|
166
|
+
s = _decorate_str(s, item.important?) if color_p
|
167
|
+
sb << s << "\n"
|
163
168
|
#; [!848rm] supports multi-lines help message.
|
169
|
+
detail = item.detail
|
164
170
|
if detail
|
165
171
|
width ||= (format % ['', '']).length
|
166
172
|
indent ||= ' ' * width
|
@@ -276,12 +282,20 @@ module Benry::CmdOpt
|
|
276
282
|
return short_p ? 8 : long_p ? 20 : 14
|
277
283
|
end
|
278
284
|
|
285
|
+
def _decorate_str(str, important)
|
286
|
+
case important
|
287
|
+
when true ; return "\e[1m#{str}\e[0m" # bold
|
288
|
+
when false ; return "\e[2m#{str}\e[0m" # gray
|
289
|
+
else ; return str
|
290
|
+
end
|
291
|
+
end
|
292
|
+
|
279
293
|
end
|
280
294
|
|
281
295
|
|
282
296
|
class SchemaItem # avoid Struct
|
283
297
|
|
284
|
-
def initialize(key, optdef, desc, short, long, param, required, type: nil, rexp: nil, pattern: nil, enum: nil, range: nil, detail: nil, value: nil, tag: nil, &callback)
|
298
|
+
def initialize(key, optdef, desc, short, long, param, required, type: nil, rexp: nil, pattern: nil, enum: nil, range: nil, detail: nil, value: nil, hidden: nil, important: nil, tag: nil, &callback)
|
285
299
|
rexp ||= pattern # for backward compatibility
|
286
300
|
_init_validation(param, required, type, rexp, enum, range, value)
|
287
301
|
@key = key unless nil == key
|
@@ -297,6 +311,8 @@ module Benry::CmdOpt
|
|
297
311
|
@range = range unless nil == range
|
298
312
|
@detail = detail unless nil == detail
|
299
313
|
@value = value unless nil == value
|
314
|
+
@hidden = hidden unless nil == hidden
|
315
|
+
@important = important unless nil == important
|
300
316
|
@tag = tag unless nil == tag
|
301
317
|
@callback = callback unless nil == callback
|
302
318
|
#; [!nn4cp] freezes enum object.
|
@@ -324,10 +340,18 @@ module Benry::CmdOpt
|
|
324
340
|
end
|
325
341
|
|
326
342
|
def hidden?()
|
343
|
+
#; [!no6ov] returns true if @hidden is true.
|
344
|
+
#; [!ej8ot] returns false if @hidden is false.
|
345
|
+
return @hidden if @hidden != nil
|
327
346
|
#; [!h0uxs] returns true if desc is nil.
|
328
|
-
#; [!su00g] returns true if key starts with '_'.
|
329
347
|
#; [!28vzx] returns false if else.
|
330
|
-
return @desc == nil
|
348
|
+
return @desc == nil
|
349
|
+
end
|
350
|
+
|
351
|
+
def important?()
|
352
|
+
#; [!ua8kt] returns true/false if `important:` kwarg passed to constructor.
|
353
|
+
#; [!hz9sx] returns nil if `important:` kwarg not passed to constructor.
|
354
|
+
return @important
|
331
355
|
end
|
332
356
|
|
333
357
|
def validate_and_convert(val, optdict)
|
data/test/cmdopt_test.rb
CHANGED
@@ -342,13 +342,49 @@ END
|
|
342
342
|
spec "[!a4qe4] option should not be hidden if description is empty string." do
|
343
343
|
sc = Benry::CmdOpt::Schema.new
|
344
344
|
sc.add(:debug , "-D", nil) # hidden
|
345
|
-
sc.add(:
|
345
|
+
sc.add(:trace, "-T", "trace", hidden: true) # hidden
|
346
346
|
sc.add(:what , "-W", "") # NOT hidden!
|
347
347
|
ok {sc.option_help()} == <<END
|
348
348
|
-W :
|
349
349
|
END
|
350
350
|
end
|
351
351
|
|
352
|
+
fixture :schema_with_importance do
|
353
|
+
sc = Benry::CmdOpt::Schema.new
|
354
|
+
sc.add(:help , "-h, --help" , "help message")
|
355
|
+
sc.add(:trace , "-T, --trace", "trace" , important: true)
|
356
|
+
sc.add(:debug , "-D, --debug", "debug mode" , important: false)
|
357
|
+
sc.add(:quiet , "-q, --quiet", "quiet mode")
|
358
|
+
sc
|
359
|
+
end
|
360
|
+
|
361
|
+
spec "[!jrwb6] decorates help message according to `important:` value of option." do
|
362
|
+
|schema_with_importance|
|
363
|
+
sc = schema_with_importance
|
364
|
+
ok {sc.option_help()} == <<END
|
365
|
+
-h, --help : help message
|
366
|
+
\e[1m -T, --trace : trace\e[0m
|
367
|
+
\e[2m -D, --debug : debug mode\e[0m
|
368
|
+
-q, --quiet : quiet mode
|
369
|
+
END
|
370
|
+
end
|
371
|
+
|
372
|
+
spec "[!9nlfb] not decorate help message when stdout is not a tty." do
|
373
|
+
|schema_with_importance|
|
374
|
+
sc = schema_with_importance
|
375
|
+
output = nil
|
376
|
+
capture_sio() {
|
377
|
+
ok {$stdout}.NOT.tty?
|
378
|
+
output = sc.option_help()
|
379
|
+
}
|
380
|
+
ok {output} == <<END
|
381
|
+
-h, --help : help message
|
382
|
+
-T, --trace : trace
|
383
|
+
-D, --debug : debug mode
|
384
|
+
-q, --quiet : quiet mode
|
385
|
+
END
|
386
|
+
end
|
387
|
+
|
352
388
|
end
|
353
389
|
|
354
390
|
|
@@ -445,7 +481,7 @@ END
|
|
445
481
|
sc.add(:help, "-h, --help", "show help message")
|
446
482
|
sc.add(:version, " --version", "print version")
|
447
483
|
sc.add(:debug , "-d, --debug" , nil) # hidden
|
448
|
-
sc.add(:
|
484
|
+
sc.add(:DEBUG , "-D, --DEBUG" , "debug mode", hidden: true) # hidden
|
449
485
|
@schema = sc
|
450
486
|
end
|
451
487
|
|
@@ -532,7 +568,7 @@ END
|
|
532
568
|
spec "[!icvm1] ignores hidden items if 'all: false' kwarg specified." do
|
533
569
|
schema = Benry::CmdOpt::Schema.new
|
534
570
|
schema.add(:debug , "-D", nil)
|
535
|
-
schema.add(:
|
571
|
+
schema.add(:trace, "-T", "trace", hidden: true)
|
536
572
|
ok {schema.empty?()} == false
|
537
573
|
ok {schema.empty?(all: true)} == false
|
538
574
|
ok {schema.empty?(all: false)} == true
|
@@ -898,15 +934,19 @@ END
|
|
898
934
|
|
899
935
|
topic '#hidden?()' do
|
900
936
|
|
901
|
-
spec "[!
|
902
|
-
|
903
|
-
item = Benry::CmdOpt::SchemaItem.new(:debug, "-D", desc, "D", nil, nil, nil)
|
937
|
+
spec "[!no6ov] returns true if @hidden is true." do
|
938
|
+
item = Benry::CmdOpt::SchemaItem.new(:debug, "-D", "debug mode", "D", nil, nil, nil, hidden: true)
|
904
939
|
ok {item.hidden?} == true
|
905
940
|
end
|
906
941
|
|
907
|
-
spec "[!
|
908
|
-
|
909
|
-
item
|
942
|
+
spec "[!ej8ot] returns false if @hidden is false." do
|
943
|
+
item = Benry::CmdOpt::SchemaItem.new(:debug, "-D", "debug mode", "D", nil, nil, nil, hidden: false)
|
944
|
+
ok {item.hidden?} == false
|
945
|
+
end
|
946
|
+
|
947
|
+
spec "[!h0uxs] returns true if desc is nil." do
|
948
|
+
desc = nil
|
949
|
+
item = Benry::CmdOpt::SchemaItem.new(:debug, "-D", desc, "D", nil, nil, nil)
|
910
950
|
ok {item.hidden?} == true
|
911
951
|
end
|
912
952
|
|
@@ -919,6 +959,23 @@ END
|
|
919
959
|
end
|
920
960
|
|
921
961
|
|
962
|
+
topic '#important?()' do
|
963
|
+
|
964
|
+
spec "[!ua8kt] returns true/false if `important:` kwarg passed to constructor." do
|
965
|
+
item1 = Benry::CmdOpt::SchemaItem.new(:debug, "-D", "debug mode", "D", nil, nil, nil, important: true)
|
966
|
+
ok {item1.important?} == true
|
967
|
+
item2 = Benry::CmdOpt::SchemaItem.new(:debug, "-D", "debug mode", "D", nil, nil, nil, important: false)
|
968
|
+
ok {item2.important?} == false
|
969
|
+
end
|
970
|
+
|
971
|
+
spec "[!hz9sx] returns nil if `important:` kwarg not passed to constructor." do
|
972
|
+
item3 = Benry::CmdOpt::SchemaItem.new(:debug, "-D", "debug mode", "D", nil, nil, nil)
|
973
|
+
ok {item3.important?} == nil
|
974
|
+
end
|
975
|
+
|
976
|
+
end
|
977
|
+
|
978
|
+
|
922
979
|
topic '#validate_and_convert()' do
|
923
980
|
|
924
981
|
def new_item(key, optstr, desc, short, long, param, required,
|
@@ -1520,7 +1577,7 @@ END
|
|
1520
1577
|
@cmdopt.add(:help , "-h, --help" , "show help message")
|
1521
1578
|
@cmdopt.add(:version, " --version" , "print version")
|
1522
1579
|
@cmdopt.add(:debug , "-D" , nil) # hidden option
|
1523
|
-
@cmdopt.add(:
|
1580
|
+
@cmdopt.add(:trace , "-T" , "trace", hidden: true) # hidden option
|
1524
1581
|
end
|
1525
1582
|
|
1526
1583
|
spec "[!bw9qx] yields each option definition string and help message." do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: benry-cmdopt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kwatch
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-10-
|
11
|
+
date: 2023-10-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: oktest
|