cl 0.1.28 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/Gemfile +1 -0
- data/Gemfile.lock +19 -1
- data/NOTES.md +2 -0
- data/README.md +210 -142
- data/examples/args/cast +53 -41
- data/examples/args/opts +72 -14
- data/examples/args/required +28 -14
- data/examples/args/splat +29 -32
- data/examples/gem +26 -37
- data/examples/heroku +15 -16
- data/examples/rakeish +13 -15
- data/examples/readme/abstract +6 -5
- data/examples/readme/alias +4 -7
- data/examples/readme/arg +4 -2
- data/examples/readme/arg_array +4 -2
- data/examples/readme/arg_type +3 -1
- data/examples/readme/args_splat +13 -4
- data/examples/readme/default +2 -2
- data/examples/readme/deprecated +3 -6
- data/examples/readme/deprecated_alias +2 -4
- data/examples/readme/downcase +2 -2
- data/examples/readme/enum +10 -5
- data/examples/readme/example +6 -4
- data/examples/readme/format +9 -7
- data/examples/readme/internal +8 -4
- data/examples/readme/negate +20 -5
- data/examples/readme/node +19 -0
- data/examples/readme/opts +8 -8
- data/examples/readme/opts_block +4 -3
- data/examples/readme/range +9 -7
- data/examples/readme/required +9 -7
- data/examples/readme/requireds +26 -18
- data/examples/readme/requires +13 -14
- data/examples/readme/secret +7 -9
- data/examples/readme/see +6 -8
- data/examples/readme/type +2 -6
- data/examples/src/args/cast.erb.rb +96 -0
- data/examples/src/args/opts.erb.rb +96 -0
- data/examples/src/args/required.erb.rb +61 -0
- data/examples/src/args/splat.erb.rb +55 -0
- data/examples/src/gem.erb.rb +95 -0
- data/examples/src/heroku.erb.rb +47 -0
- data/examples/src/rakeish.erb.rb +54 -0
- data/examples/src/readme/abstract.erb.rb +25 -0
- data/examples/src/readme/alias.erb.rb +20 -0
- data/examples/src/readme/arg.erb.rb +19 -0
- data/examples/src/readme/arg_array.erb.rb +19 -0
- data/examples/src/readme/arg_type.erb.rb +21 -0
- data/examples/src/readme/args_splat.erb.rb +49 -0
- data/examples/src/readme/array.erb.rb +19 -0
- data/examples/src/readme/default.erb.rb +19 -0
- data/examples/src/readme/deprecated.erb.rb +19 -0
- data/examples/src/readme/deprecated_alias.erb.rb +19 -0
- data/examples/src/readme/downcase.erb.rb +19 -0
- data/examples/src/readme/enum.erb.rb +33 -0
- data/examples/src/readme/example.erb.rb +23 -0
- data/examples/src/readme/format.erb.rb +33 -0
- data/examples/src/readme/internal.erb.rb +26 -0
- data/examples/src/readme/negate.erb.rb +35 -0
- data/examples/src/readme/node.erb.rb +23 -0
- data/examples/src/readme/opts.erb.rb +31 -0
- data/examples/src/readme/opts_block.erb.rb +28 -0
- data/examples/src/readme/range.erb.rb +33 -0
- data/examples/src/readme/required.erb.rb +33 -0
- data/examples/src/readme/requireds.erb.rb +44 -0
- data/examples/src/readme/requires.erb.rb +33 -0
- data/examples/src/readme/secret.erb.rb +20 -0
- data/examples/src/readme/see.erb.rb +23 -0
- data/examples/src/readme/type.erb.rb +19 -0
- data/lib/cl/ui.rb +2 -2
- data/lib/cl/version.rb +1 -1
- metadata +40 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 8e6ef1ee5a1de5a6db0abe39ce38d2e2cce9acd93ea525b456fdb3a06b80022f
|
4
|
+
data.tar.gz: 7fb5f6eaf119649982149be1ac54a367ed85188e63acfb85d4ed422e72620e3b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d8e3e6454c83f588383b713af70cf43d69f7914349eabcb07586045e45aa2ee44cae7f7be7ad86438800213270791fdae8047e52f7ec971fa36217956a093cf7
|
7
|
+
data.tar.gz: ebbdafe93266703989144983f919fa79325c5797c1cfe831a83b5a8e3c7a04d5042e7b2c3ab1ea5553319c105d1d916e6b8e2ab70ef711000be2e861d95fbd2d
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,13 +1,21 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
cl (0.1.
|
4
|
+
cl (0.1.28)
|
5
5
|
regstry (~> 1.0.3)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
+
coveralls (0.8.23)
|
11
|
+
json (>= 1.8, < 3)
|
12
|
+
simplecov (~> 0.16.1)
|
13
|
+
term-ansicolor (~> 1.3)
|
14
|
+
thor (>= 0.19.4, < 2.0)
|
15
|
+
tins (~> 1.6)
|
10
16
|
diff-lcs (1.3)
|
17
|
+
docile (1.3.2)
|
18
|
+
json (2.2.0)
|
11
19
|
memfs (1.0.0)
|
12
20
|
regstry (1.0.14)
|
13
21
|
rspec (3.8.0)
|
@@ -23,12 +31,22 @@ GEM
|
|
23
31
|
diff-lcs (>= 1.2.0, < 2.0)
|
24
32
|
rspec-support (~> 3.8.0)
|
25
33
|
rspec-support (3.8.0)
|
34
|
+
simplecov (0.16.1)
|
35
|
+
docile (~> 1.1)
|
36
|
+
json (>= 1.8, < 3)
|
37
|
+
simplecov-html (~> 0.10.0)
|
38
|
+
simplecov-html (0.10.2)
|
39
|
+
term-ansicolor (1.7.1)
|
40
|
+
tins (~> 1.0)
|
41
|
+
thor (0.20.3)
|
42
|
+
tins (1.21.1)
|
26
43
|
|
27
44
|
PLATFORMS
|
28
45
|
ruby
|
29
46
|
|
30
47
|
DEPENDENCIES
|
31
48
|
cl!
|
49
|
+
coveralls
|
32
50
|
memfs
|
33
51
|
rspec
|
34
52
|
|
data/NOTES.md
CHANGED
@@ -11,3 +11,5 @@ x add toc
|
|
11
11
|
x add yard docs
|
12
12
|
|
13
13
|
- refactor Help::Cmd and Table so that everything goes into one big table
|
14
|
+
- Ui classes really need to write error messages to stderr, not stdout
|
15
|
+
- make sure option aliases define accessors and predicates (see examples/readme/alias)
|
data/README.md
CHANGED
@@ -1,15 +1,12 @@
|
|
1
|
-
# Cl [![Build Status](https://travis-ci.org/svenfuchs/cl.svg?branch=master)](https://travis-ci.
|
1
|
+
# Cl [![Build Status](https://travis-ci.org/svenfuchs/cl.svg?branch=master)](https://travis-ci.com/svenfuchs/cl) [![Code Climate](https://codeclimate.com/github/svenfuchs/cl.png)](https://codeclimate.com/github/svenfuchs/cl) [![Coverage Status](https://coveralls.io/repos/github/svenfuchs/cl/badge.svg?branch=master)](https://coveralls.io/github/svenfuchs/cl?branch=master) [![Rubydocs](http://img.shields.io/badge/yard-docs-blue.svg)](http://rubydoc.info/github/svenfuchs/cl) [![Gem Version](https://img.shields.io/gem/v/cl)](http://rubygems.org/gems/cl)
|
2
2
|
|
3
3
|
OptionParser based CLI support for rapid CLI development in an object-oriented
|
4
4
|
context.
|
5
5
|
|
6
|
-
This library wraps Ruby's OptionParser
|
7
|
-
|
6
|
+
This library wraps Ruby's OptionParser for parsing your options under the hood,
|
7
|
+
so you get all the goodness that the Ruby standard library provides.
|
8
8
|
|
9
|
-
|
10
|
-
the goodness that this library provides.
|
11
|
-
|
12
|
-
But on top of that it also provides a rich DSL for defining, validating, and
|
9
|
+
On top of that it adds a rich and powerful DSL for defining, validating, and
|
13
10
|
normalizing options, as well as automatic and gorgeous help output (modeled
|
14
11
|
after `gem --help`).
|
15
12
|
|
@@ -277,19 +274,20 @@ class Base < Cl::Cmd
|
|
277
274
|
end
|
278
275
|
|
279
276
|
class Add < Base
|
277
|
+
def run
|
278
|
+
puts 'Success'
|
279
|
+
end
|
280
280
|
end
|
281
281
|
|
282
|
-
Cl.new('owners').
|
282
|
+
Cl.new('owners').run(%w(add))
|
283
283
|
|
284
284
|
# Output:
|
285
285
|
#
|
286
|
-
#
|
287
|
-
#
|
288
|
-
# owners add [options]
|
286
|
+
# Success
|
289
287
|
|
290
288
|
Cl.new('owners').run(%w(base))
|
291
289
|
|
292
|
-
#
|
290
|
+
# Output:
|
293
291
|
#
|
294
292
|
# Unknown command: base
|
295
293
|
|
@@ -311,13 +309,15 @@ class Add < Cl::Cmd
|
|
311
309
|
arg :owner
|
312
310
|
|
313
311
|
def run
|
314
|
-
p owner
|
312
|
+
p owner: owner
|
315
313
|
end
|
316
314
|
end
|
317
315
|
|
318
316
|
Cl.new('owners').run(%w(add one))
|
319
317
|
|
320
|
-
#
|
318
|
+
# Output:
|
319
|
+
#
|
320
|
+
# {:owner=>"one"}
|
321
321
|
|
322
322
|
```
|
323
323
|
|
@@ -337,13 +337,15 @@ class Add < Cl::Cmd
|
|
337
337
|
arg :owners, type: :array, sep: ','
|
338
338
|
|
339
339
|
def run
|
340
|
-
p owners
|
340
|
+
p owners: owners
|
341
341
|
end
|
342
342
|
end
|
343
343
|
|
344
344
|
Cl.new('owners').run(%w(add one,two))
|
345
345
|
|
346
|
-
#
|
346
|
+
# Output:
|
347
|
+
#
|
348
|
+
# {:owners=>["one", "two"]}
|
347
349
|
|
348
350
|
```
|
349
351
|
|
@@ -362,7 +364,9 @@ end
|
|
362
364
|
|
363
365
|
Cl.new('owners').run(%w(cmd 1 2.1 yes))
|
364
366
|
|
365
|
-
#
|
367
|
+
# Output:
|
368
|
+
#
|
369
|
+
# [Integer, Float, TrueClass]
|
366
370
|
|
367
371
|
```
|
368
372
|
|
@@ -373,19 +377,53 @@ Array arguments support splats, modeled after Ruby argument splats.
|
|
373
377
|
For example:
|
374
378
|
|
375
379
|
```ruby
|
376
|
-
class
|
377
|
-
arg :
|
378
|
-
arg :
|
379
|
-
arg :
|
380
|
+
class Lft < Cl::Cmd
|
381
|
+
arg :a, type: :array, splat: true
|
382
|
+
arg :b
|
383
|
+
arg :c
|
380
384
|
|
381
385
|
def run
|
382
|
-
p [
|
386
|
+
p [a, b, c]
|
383
387
|
end
|
384
388
|
end
|
385
389
|
|
386
|
-
|
390
|
+
class Mid < Cl::Cmd
|
391
|
+
arg :a
|
392
|
+
arg :b, type: :array, splat: true
|
393
|
+
arg :c
|
394
|
+
|
395
|
+
def run
|
396
|
+
p [a, b, c]
|
397
|
+
end
|
398
|
+
end
|
399
|
+
|
400
|
+
class Rgt < Cl::Cmd
|
401
|
+
arg :a
|
402
|
+
arg :b
|
403
|
+
arg :c, type: :array, splat: true
|
404
|
+
|
405
|
+
def run
|
406
|
+
p [a, b, c]
|
407
|
+
end
|
408
|
+
end
|
409
|
+
|
410
|
+
Cl.new('splat').run(%w(lft 1 2 3 4 5))
|
411
|
+
|
412
|
+
# Output:
|
413
|
+
#
|
414
|
+
# [["1", "2", "3"], "4", "5"]
|
415
|
+
|
416
|
+
Cl.new('splat').run(%w(mid 1 2 3 4 5))
|
417
|
+
|
418
|
+
# Output:
|
419
|
+
#
|
420
|
+
# ["1", ["2", "3", "4"], "5"]
|
387
421
|
|
388
|
-
|
422
|
+
Cl.new('splat').run(%w(rgt 1 2 3 4 5))
|
423
|
+
|
424
|
+
# Output:
|
425
|
+
#
|
426
|
+
# ["1", "2", ["3", "4", "5"]]
|
389
427
|
|
390
428
|
```
|
391
429
|
|
@@ -404,7 +442,7 @@ class Add < Cl::Cmd
|
|
404
442
|
opt '--to GROUP', 'Target group to add owners to'
|
405
443
|
|
406
444
|
def run
|
407
|
-
p opts, to, to?
|
445
|
+
p opts: opts, to: to, to?: to?
|
408
446
|
end
|
409
447
|
end
|
410
448
|
|
@@ -412,18 +450,18 @@ Cl.new('owners').run(%w(add --to one))
|
|
412
450
|
|
413
451
|
# Output:
|
414
452
|
#
|
415
|
-
# {
|
416
|
-
# "one"
|
417
|
-
# true
|
453
|
+
# {:opts=>{:to=>"one"}, :to=>"one", :to?=>true}
|
418
454
|
|
419
455
|
Cl.new('owners').run(%w(add --help))
|
420
456
|
|
421
|
-
#
|
457
|
+
# Output:
|
422
458
|
#
|
423
|
-
#
|
459
|
+
# Usage: owners add [options]
|
424
460
|
#
|
425
|
-
#
|
426
|
-
#
|
461
|
+
# Options:
|
462
|
+
#
|
463
|
+
# --to GROUP Target group to add owners to (type: string)
|
464
|
+
# --help Get help on this command
|
427
465
|
|
428
466
|
```
|
429
467
|
|
@@ -442,11 +480,11 @@ class Add < Cl::Cmd
|
|
442
480
|
# * value, name, type
|
443
481
|
# * value, name, type, opts
|
444
482
|
opt '--to GROUP' do |value|
|
445
|
-
opts[:to] = "
|
483
|
+
opts[:to] = "group-#{value}"
|
446
484
|
end
|
447
485
|
|
448
486
|
def run
|
449
|
-
p to
|
487
|
+
p to: to
|
450
488
|
end
|
451
489
|
end
|
452
490
|
|
@@ -454,7 +492,8 @@ Cl.new('owners').run(%w(add --to one))
|
|
454
492
|
|
455
493
|
# Output:
|
456
494
|
#
|
457
|
-
# "
|
495
|
+
# {:to=>"group-one"}
|
496
|
+
|
458
497
|
|
459
498
|
```
|
460
499
|
|
@@ -467,19 +506,16 @@ class Add < Cl::Cmd
|
|
467
506
|
opt '--to GROUP', alias: :group
|
468
507
|
|
469
508
|
def run
|
470
|
-
p opts, to, to?, group, group?
|
509
|
+
# p opts: opts, to: to, to?: to?, group: group, group?: group?
|
510
|
+
p opts: opts, to: to, to?: to?
|
471
511
|
end
|
472
512
|
end
|
473
513
|
|
474
|
-
Cl.new('owners').run(%w(add --
|
514
|
+
Cl.new('owners').run(%w(add --group one))
|
475
515
|
|
476
516
|
# Output:
|
477
517
|
#
|
478
|
-
# {
|
479
|
-
# "one"
|
480
|
-
# true
|
481
|
-
# "one"
|
482
|
-
# true
|
518
|
+
# {:opts=>{:to=>"one", :group=>"one"}, :to=>"one", :to?=>true}
|
483
519
|
|
484
520
|
```
|
485
521
|
|
@@ -494,7 +530,7 @@ class Add < Cl::Cmd
|
|
494
530
|
opt '--to GROUP', default: 'default'
|
495
531
|
|
496
532
|
def run
|
497
|
-
p to
|
533
|
+
p to: to
|
498
534
|
end
|
499
535
|
end
|
500
536
|
|
@@ -502,7 +538,7 @@ Cl.new('owners').run(%w(add))
|
|
502
538
|
|
503
539
|
# Output:
|
504
540
|
#
|
505
|
-
# "default"
|
541
|
+
# {:to=>"default"}
|
506
542
|
|
507
543
|
```
|
508
544
|
|
@@ -514,11 +550,10 @@ For a deprecated option:
|
|
514
550
|
|
515
551
|
```ruby
|
516
552
|
class Add < Cl::Cmd
|
517
|
-
opt '--
|
518
|
-
opt '--target GROUP', deprecated: 'Deprecated: --target'
|
553
|
+
opt '--target GROUP', deprecated: 'Deprecated.'
|
519
554
|
|
520
555
|
def run
|
521
|
-
p
|
556
|
+
p target: target, deprecations: deprecations
|
522
557
|
end
|
523
558
|
end
|
524
559
|
|
@@ -526,9 +561,7 @@ Cl.new('owners').run(%w(add --target one))
|
|
526
561
|
|
527
562
|
# Output:
|
528
563
|
#
|
529
|
-
# "one"
|
530
|
-
# {:target=>'Deprecated: --target'}
|
531
|
-
|
564
|
+
# {:target=>"one", :deprecations=>{:target=>"Deprecated."}}
|
532
565
|
|
533
566
|
```
|
534
567
|
|
@@ -539,7 +572,7 @@ class Add < Cl::Cmd
|
|
539
572
|
opt '--to GROUP', alias: :target, deprecated: :target
|
540
573
|
|
541
574
|
def run
|
542
|
-
p to,
|
575
|
+
p to: to, deprecations: deprecations
|
543
576
|
end
|
544
577
|
end
|
545
578
|
|
@@ -547,9 +580,7 @@ Cl.new('owners').run(%w(add --target one))
|
|
547
580
|
|
548
581
|
# Output:
|
549
582
|
#
|
550
|
-
# "one"
|
551
|
-
# {:target=>:to}
|
552
|
-
|
583
|
+
# {:to=>"one", :deprecations=>{:target=>:to}}
|
553
584
|
|
554
585
|
```
|
555
586
|
|
@@ -564,7 +595,7 @@ class Add < Cl::Cmd
|
|
564
595
|
opt '--to GROUP', downcase: true
|
565
596
|
|
566
597
|
def run
|
567
|
-
p to
|
598
|
+
p to: to
|
568
599
|
end
|
569
600
|
end
|
570
601
|
|
@@ -572,7 +603,7 @@ Cl.new('owners').run(%w(add --to ONE))
|
|
572
603
|
|
573
604
|
# Output:
|
574
605
|
#
|
575
|
-
# "one"
|
606
|
+
# {:to=>"one"}
|
576
607
|
|
577
608
|
```
|
578
609
|
|
@@ -590,7 +621,7 @@ class Add < Cl::Cmd
|
|
590
621
|
opt '--to GROUP', enum: %w(one two)
|
591
622
|
|
592
623
|
def run
|
593
|
-
p to
|
624
|
+
p to: to
|
594
625
|
end
|
595
626
|
end
|
596
627
|
|
@@ -598,15 +629,20 @@ Cl.new('owners').run(%w(add --to one))
|
|
598
629
|
|
599
630
|
# Output:
|
600
631
|
#
|
601
|
-
# "one"
|
632
|
+
# {:to=>"one"}
|
602
633
|
|
603
634
|
Cl.new('owners').run(%w(add --to unknown))
|
604
635
|
|
605
|
-
#
|
636
|
+
# Output:
|
606
637
|
#
|
607
|
-
#
|
638
|
+
# Unknown value: to=unknown (known values: one, two)
|
608
639
|
#
|
609
|
-
#
|
640
|
+
# Usage: owners add [options]
|
641
|
+
#
|
642
|
+
# Options:
|
643
|
+
#
|
644
|
+
# --to GROUP type: string, known values: one, two
|
645
|
+
# --help Get help on this command
|
610
646
|
|
611
647
|
```
|
612
648
|
|
@@ -621,12 +657,14 @@ end
|
|
621
657
|
|
622
658
|
Cl.new('owners').run(%w(add --help))
|
623
659
|
|
624
|
-
#
|
660
|
+
# Output:
|
625
661
|
#
|
626
|
-
#
|
662
|
+
# Usage: owners add [options]
|
627
663
|
#
|
628
|
-
#
|
629
|
-
#
|
664
|
+
# Options:
|
665
|
+
#
|
666
|
+
# --to GROUP type: string, e.g.: group-one
|
667
|
+
# --help Get help on this command
|
630
668
|
|
631
669
|
```
|
632
670
|
|
@@ -644,7 +682,7 @@ class Add < Cl::Cmd
|
|
644
682
|
opt '--to GROUP', format: /^\w+$/
|
645
683
|
|
646
684
|
def run
|
647
|
-
p to
|
685
|
+
p to: to
|
648
686
|
end
|
649
687
|
end
|
650
688
|
|
@@ -652,18 +690,20 @@ Cl.new('owners').run(%w(add --to one))
|
|
652
690
|
|
653
691
|
# Output:
|
654
692
|
#
|
655
|
-
# "one"
|
693
|
+
# {:to=>"one"}
|
656
694
|
|
657
695
|
Cl.new('owners').run(['add', '--to', 'does not match!'])
|
658
696
|
|
659
|
-
#
|
697
|
+
# Output:
|
660
698
|
#
|
661
|
-
#
|
699
|
+
# Invalid format: to (format: /^\w+$/)
|
662
700
|
#
|
663
|
-
#
|
701
|
+
# Usage: owners add [options]
|
664
702
|
#
|
665
|
-
#
|
666
|
-
#
|
703
|
+
# Options:
|
704
|
+
#
|
705
|
+
# --to GROUP type: string, format: /^\w+$/
|
706
|
+
# --help Get help on this command
|
667
707
|
|
668
708
|
```
|
669
709
|
|
@@ -681,12 +721,14 @@ end
|
|
681
721
|
|
682
722
|
Cl.new('owners').run(%w(add --help))
|
683
723
|
|
684
|
-
#
|
724
|
+
# Output:
|
685
725
|
#
|
686
|
-
#
|
726
|
+
# Usage: owners add [options]
|
687
727
|
#
|
688
|
-
#
|
689
|
-
#
|
728
|
+
# Options:
|
729
|
+
#
|
730
|
+
# --to GROUP type: string
|
731
|
+
# --help Get help on this command
|
690
732
|
|
691
733
|
```
|
692
734
|
|
@@ -705,7 +747,7 @@ class Add < Cl::Cmd
|
|
705
747
|
opt '--retries COUNT', type: :integer, min: 1, max: 5
|
706
748
|
|
707
749
|
def run
|
708
|
-
p retries
|
750
|
+
p retries: retries
|
709
751
|
end
|
710
752
|
end
|
711
753
|
|
@@ -713,18 +755,20 @@ Cl.new('owners').run(%w(add --retries 1))
|
|
713
755
|
|
714
756
|
# Output:
|
715
757
|
#
|
716
|
-
# 1
|
758
|
+
# {:retries=>1}
|
717
759
|
|
718
760
|
Cl.new('owners').run(%w(add --retries 10))
|
719
761
|
|
720
|
-
#
|
762
|
+
# Output:
|
721
763
|
#
|
722
|
-
#
|
764
|
+
# Out of range: retries (min: 1, max: 5)
|
723
765
|
#
|
724
|
-
#
|
766
|
+
# Usage: owners add [options]
|
767
|
+
#
|
768
|
+
# Options:
|
725
769
|
#
|
726
|
-
#
|
727
|
-
#
|
770
|
+
# --retries COUNT type: integer, min: 1, max: 5
|
771
|
+
# --help Get help on this command
|
728
772
|
|
729
773
|
```
|
730
774
|
|
@@ -745,19 +789,34 @@ class Add < Cl::Cmd
|
|
745
789
|
end
|
746
790
|
|
747
791
|
Cl.new('owners').run(%w(add --notifications))
|
748
|
-
|
792
|
+
|
793
|
+
# Output:
|
794
|
+
#
|
795
|
+
# true
|
749
796
|
|
750
797
|
Cl.new('owners').run(%w(add --no_notifications))
|
751
|
-
|
798
|
+
|
799
|
+
# Output:
|
800
|
+
#
|
801
|
+
# false
|
752
802
|
|
753
803
|
Cl.new('owners').run(%w(add --no-notifications))
|
754
|
-
|
804
|
+
|
805
|
+
# Output:
|
806
|
+
#
|
807
|
+
# false
|
755
808
|
|
756
809
|
Cl.new('owners').run(%w(add --skip_notifications))
|
757
|
-
|
810
|
+
|
811
|
+
# Output:
|
812
|
+
#
|
813
|
+
# false
|
758
814
|
|
759
815
|
Cl.new('owners').run(%w(add --skip-notifications))
|
760
|
-
|
816
|
+
|
817
|
+
# Output:
|
818
|
+
#
|
819
|
+
# false
|
761
820
|
|
762
821
|
```
|
763
822
|
|
@@ -791,21 +850,21 @@ on this in order to, for example, obfuscate values from log output.
|
|
791
850
|
|
792
851
|
```ruby
|
793
852
|
class Add < Cl::Cmd
|
794
|
-
opt '--
|
795
|
-
opt '--password PASS', secret: true
|
853
|
+
opt '--pass PASS', secret: true
|
796
854
|
|
797
855
|
def run
|
798
|
-
|
799
|
-
|
856
|
+
p(
|
857
|
+
secret?: self.class.opts[:pass].secret?,
|
858
|
+
tainted?: pass.tainted?
|
859
|
+
)
|
800
860
|
end
|
801
861
|
end
|
802
862
|
|
803
|
-
Cl.new('owners').run(%w(add --
|
863
|
+
Cl.new('owners').run(%w(add --pass pass))
|
804
864
|
|
805
865
|
# Output:
|
806
866
|
#
|
807
|
-
# secret
|
808
|
-
# tainted? true
|
867
|
+
# {:secret?=>true, :tainted?=>true}
|
809
868
|
|
810
869
|
```
|
811
870
|
|
@@ -819,20 +878,18 @@ For example:
|
|
819
878
|
```ruby
|
820
879
|
class Add < Cl::Cmd
|
821
880
|
opt '--to GROUP', see: 'https://docs.io/cli/owners/add'
|
822
|
-
|
823
|
-
def run
|
824
|
-
p retries
|
825
|
-
end
|
826
881
|
end
|
827
882
|
|
828
883
|
Cl.new('owners').run(%w(add --help))
|
829
884
|
|
830
|
-
#
|
885
|
+
# Output:
|
831
886
|
#
|
832
|
-
#
|
887
|
+
# Usage: owners add [options]
|
833
888
|
#
|
834
|
-
#
|
835
|
-
#
|
889
|
+
# Options:
|
890
|
+
#
|
891
|
+
# --to GROUP type: string, see: https://docs.io/cli/owners/add
|
892
|
+
# --help Get help on this command
|
836
893
|
|
837
894
|
```
|
838
895
|
|
@@ -871,7 +928,7 @@ class Add < Cl::Cmd
|
|
871
928
|
opt '--sleep FLOAT', type: :float
|
872
929
|
|
873
930
|
def run
|
874
|
-
p active.class, retries.class, sleep.class
|
931
|
+
p active: active.class, retries: retries.class, sleep: sleep.class
|
875
932
|
end
|
876
933
|
end
|
877
934
|
|
@@ -879,9 +936,7 @@ Cl.new('owners').run(%w(add --active yes --retries 1 --sleep 0.1))
|
|
879
936
|
|
880
937
|
# Output:
|
881
938
|
#
|
882
|
-
# TrueClass
|
883
|
-
# Integer
|
884
|
-
# Float
|
939
|
+
# {:active=>TrueClass, :retries=>Integer, :sleep=>Float}
|
885
940
|
|
886
941
|
```
|
887
942
|
|
@@ -900,7 +955,7 @@ class Add < Cl::Cmd
|
|
900
955
|
opt '--to GROUP', required: true
|
901
956
|
|
902
957
|
def run
|
903
|
-
p to
|
958
|
+
p to: to
|
904
959
|
end
|
905
960
|
end
|
906
961
|
|
@@ -908,18 +963,20 @@ Cl.new('owners').run(%w(add --to one))
|
|
908
963
|
|
909
964
|
# Output:
|
910
965
|
#
|
911
|
-
# "one"
|
966
|
+
# {:to=>"one"}
|
912
967
|
|
913
968
|
Cl.new('owners').run(%w(add))
|
914
969
|
|
915
|
-
#
|
970
|
+
# Output:
|
916
971
|
#
|
917
|
-
#
|
972
|
+
# Missing required option: to
|
918
973
|
#
|
919
|
-
#
|
974
|
+
# Usage: owners add [options]
|
920
975
|
#
|
921
|
-
#
|
922
|
-
#
|
976
|
+
# Options:
|
977
|
+
#
|
978
|
+
# --to GROUP type: string, required: true
|
979
|
+
# --help Get help on this command
|
923
980
|
|
924
981
|
```
|
925
982
|
|
@@ -928,31 +985,32 @@ This will make the option `--retries` depend on the option `--to`:
|
|
928
985
|
```ruby
|
929
986
|
class Add < Cl::Cmd
|
930
987
|
opt '--to GROUP'
|
931
|
-
opt '--
|
988
|
+
opt '--other GROUP', requires: :to
|
932
989
|
|
933
990
|
def run
|
934
|
-
p to,
|
991
|
+
p to: to, other: other
|
935
992
|
end
|
936
993
|
end
|
937
994
|
|
938
|
-
Cl.new('owners').run(%w(add --to one --
|
995
|
+
Cl.new('owners').run(%w(add --to one --other two))
|
939
996
|
|
940
997
|
# Output:
|
941
998
|
#
|
942
|
-
# "one"
|
943
|
-
# 1
|
999
|
+
# {:to=>"one", :other=>"two"}
|
944
1000
|
|
945
|
-
Cl.new('owners').run(%w(add --
|
1001
|
+
Cl.new('owners').run(%w(add --other two))
|
946
1002
|
|
947
|
-
#
|
1003
|
+
# Output:
|
948
1004
|
#
|
949
|
-
#
|
1005
|
+
# Missing option: to (required by other)
|
950
1006
|
#
|
951
|
-
#
|
1007
|
+
# Usage: owners add [options]
|
1008
|
+
#
|
1009
|
+
# Options:
|
952
1010
|
#
|
953
|
-
#
|
954
|
-
#
|
955
|
-
#
|
1011
|
+
# --to GROUP type: string
|
1012
|
+
# --other GROUP type: string, requires: to
|
1013
|
+
# --help Get help on this command
|
956
1014
|
|
957
1015
|
```
|
958
1016
|
|
@@ -961,36 +1019,46 @@ This requires either the option `--api_key` or both options `--username` and
|
|
961
1019
|
|
962
1020
|
```ruby
|
963
1021
|
class Add < Cl::Cmd
|
964
|
-
# read DNF, i.e. "
|
965
|
-
required :
|
1022
|
+
# read DNF, i.e. "token OR user AND pass
|
1023
|
+
required :token, [:user, :pass]
|
966
1024
|
|
967
|
-
opt '--
|
968
|
-
opt '--
|
969
|
-
opt '--
|
1025
|
+
opt '--token TOKEN'
|
1026
|
+
opt '--user NAME'
|
1027
|
+
opt '--pass PASS'
|
970
1028
|
|
971
1029
|
def run
|
972
|
-
p
|
1030
|
+
p token: token, user: user, pass: pass
|
973
1031
|
end
|
974
1032
|
end
|
975
1033
|
|
976
|
-
Cl.new('owners').run(%w(add --
|
1034
|
+
Cl.new('owners').run(%w(add --token token))
|
977
1035
|
|
978
1036
|
# Output:
|
979
1037
|
#
|
980
|
-
# "
|
981
|
-
# 1
|
1038
|
+
# {:token=>"token", :user=>nil, :pass=>nil}
|
982
1039
|
|
983
|
-
Cl.new('owners').run(%w(add --
|
1040
|
+
Cl.new('owners').run(%w(add --user user --pass pass))
|
1041
|
+
|
1042
|
+
# Output:
|
1043
|
+
#
|
1044
|
+
# {:token=>nil, :user=>"user", :pass=>"pass"}
|
1045
|
+
|
1046
|
+
Cl.new('owners').run(%w(add))
|
984
1047
|
|
985
|
-
#
|
1048
|
+
# Output:
|
986
1049
|
#
|
987
|
-
#
|
1050
|
+
# Missing options: token, or user and pass
|
988
1051
|
#
|
989
|
-
#
|
1052
|
+
# Usage: owners add [options]
|
1053
|
+
#
|
1054
|
+
# Options:
|
1055
|
+
#
|
1056
|
+
# Either token, or user and pass are required.
|
990
1057
|
#
|
991
|
-
#
|
992
|
-
#
|
993
|
-
#
|
1058
|
+
# --token TOKEN type: string
|
1059
|
+
# --user NAME type: string
|
1060
|
+
# --pass PASS type: string
|
1061
|
+
# --help Get help on this command
|
994
1062
|
|
995
1063
|
```
|
996
1064
|
|