cl 1.2.2 → 1.2.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +1 -1
  3. data/README.md +63 -10
  4. data/examples/_src/args/cast.erb.rb +4 -0
  5. data/examples/_src/args/opts.erb.rb +4 -0
  6. data/examples/_src/args/required.erb.rb +2 -0
  7. data/examples/_src/gem.erb.rb +4 -0
  8. data/examples/_src/readme/abstract.erb.rb +2 -0
  9. data/examples/_src/readme/alias.erb.rb +2 -0
  10. data/examples/_src/readme/arg.erb.rb +2 -0
  11. data/examples/_src/readme/arg_array.erb.rb +2 -0
  12. data/examples/_src/readme/arg_type.erb.rb +2 -0
  13. data/examples/_src/readme/args_splat.erb.rb +6 -0
  14. data/examples/_src/readme/array.erb.rb +2 -0
  15. data/examples/_src/readme/basic.erb.rb +2 -0
  16. data/examples/_src/readme/default.erb.rb +2 -0
  17. data/examples/_src/readme/deprecated.erb.rb +2 -0
  18. data/examples/_src/readme/deprecated_alias.erb.rb +2 -0
  19. data/examples/_src/readme/description.erb.rb +2 -0
  20. data/examples/_src/readme/downcase.erb.rb +2 -0
  21. data/examples/_src/readme/enum.erb.rb +2 -0
  22. data/examples/_src/readme/example.erb.rb +2 -0
  23. data/examples/_src/readme/format.erb.rb +2 -0
  24. data/examples/_src/readme/internal.erb.rb +2 -0
  25. data/examples/_src/readme/negate.erb.rb +2 -0
  26. data/examples/_src/readme/note.erb.rb +2 -0
  27. data/examples/_src/readme/opts.erb.rb +2 -0
  28. data/examples/_src/readme/opts_block.erb.rb +2 -0
  29. data/examples/_src/readme/range.erb.rb +2 -0
  30. data/examples/_src/readme/registry.erb.rb +2 -0
  31. data/examples/_src/readme/required.erb.rb +2 -0
  32. data/examples/_src/readme/requireds.erb.rb +2 -0
  33. data/examples/_src/readme/requires.erb.rb +2 -0
  34. data/examples/_src/readme/secret.erb.rb +2 -0
  35. data/examples/_src/readme/see.erb.rb +2 -0
  36. data/examples/_src/readme/type.erb.rb +2 -0
  37. data/examples/args/cast +4 -0
  38. data/examples/args/opts +4 -0
  39. data/examples/args/required +2 -0
  40. data/examples/gem +4 -0
  41. data/examples/readme/abstract +2 -0
  42. data/examples/readme/alias +2 -0
  43. data/examples/readme/arg +2 -0
  44. data/examples/readme/arg_array +2 -0
  45. data/examples/readme/arg_type +2 -0
  46. data/examples/readme/args_splat +6 -0
  47. data/examples/readme/array +2 -0
  48. data/examples/readme/basic +2 -0
  49. data/examples/readme/default +2 -0
  50. data/examples/readme/deprecated +2 -0
  51. data/examples/readme/deprecated_alias +2 -0
  52. data/examples/readme/description +2 -0
  53. data/examples/readme/downcase +2 -0
  54. data/examples/readme/enum +2 -0
  55. data/examples/readme/example +2 -0
  56. data/examples/readme/format +2 -0
  57. data/examples/readme/internal +2 -0
  58. data/examples/readme/negate +2 -0
  59. data/examples/readme/note +2 -0
  60. data/examples/readme/opts +2 -0
  61. data/examples/readme/opts_block +2 -0
  62. data/examples/readme/range +2 -0
  63. data/examples/readme/registry +2 -0
  64. data/examples/readme/required +2 -0
  65. data/examples/readme/requireds +2 -0
  66. data/examples/readme/requires +2 -0
  67. data/examples/readme/secret +2 -0
  68. data/examples/readme/see +2 -0
  69. data/examples/readme/type +2 -0
  70. data/lib/cl/cmd.rb +2 -1
  71. data/lib/cl/version.rb +1 -1
  72. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 310fdefbe025481f507f96657b81c0b0d4b975fe
4
- data.tar.gz: b62a11830d34ae171e26eec7782b9da20f0cf87c
3
+ metadata.gz: 78ff40e295fbf8f2e46de7150e9e769c9d27311e
4
+ data.tar.gz: 230752a72d84226fe9c9dce2153e5eee317e5039
5
5
  SHA512:
6
- metadata.gz: 4c277d6d56b2728232bb4fafa0ca368af36fef798811c34406667f0e3d4236ea00af6b3a77fd55b4809e96486f07a81272f58effd8a35e86ae2825579758c054
7
- data.tar.gz: 6b646a6350c91b113ae88e4e0474bbedeb3e57b6281dd06c70d512b332263fcc3f9e68287238d66a627aea587683f174160c7e3e923c9c5b84f38431a26a1769
6
+ metadata.gz: 0dd2f41a992417486b560bacd083effdbc985a997ed136c2e0cf9d63467e3a4c997bcdfcfa19b2fdbef17a4223f16f919be305022a370929b00ce7258d8afbbb
7
+ data.tar.gz: 4ff8c46ee20c9a5e06f74c44e152aba5323ee24b12b7d3e1620362fc295cb1bc4b330b03e5088eb3bc379c4ae7e0f073ec1d7cdee3c034c3c0f58d4fad56767b
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cl (1.2.1)
4
+ cl (1.2.2)
5
5
  regstry (~> 1.0.3)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -53,6 +53,8 @@ on CI.
53
53
  ```ruby
54
54
  module Owners
55
55
  class Add < Cl::Cmd
56
+ register :add
57
+
56
58
  summary 'Add one or more owners to an existing owner group'
57
59
 
58
60
  description <<~str
@@ -128,9 +130,11 @@ For example:
128
130
  ```ruby
129
131
  module Cmd
130
132
  class One < Cl::Cmd
133
+ register :one
131
134
  end
132
135
 
133
136
  class Two < Cl::Cmd
137
+ register :two
134
138
  end
135
139
  end
136
140
 
@@ -139,9 +143,7 @@ p Cl::Cmd[:two] # => Cmd::Two
139
143
 
140
144
  ```
141
145
 
142
- Commands auto register themselves with the underscored name of the last part of
143
- their class name (as seen in the example above). It is possible to ovewrite this
144
- key by manually registering the class, like so:
146
+ Commands can be registered like so:
145
147
 
146
148
  ```ruby
147
149
  module One
@@ -151,13 +153,6 @@ module One
151
153
  end
152
154
  ```
153
155
 
154
- Be aware that if you derive a common base command class from `Cl::Cmd` it
155
- should be declared as `abstract` in order to unregister itself from the command
156
- registry.
157
-
158
- This will prevent the runner to consider it as a runnable command, and omit it
159
- from help output. See [abstract](#abstract) for details.
160
-
161
156
  ### Runners
162
157
 
163
158
  Runners lookup the command to execute from the registry, by checking the
@@ -269,6 +264,8 @@ The description, summary, and examples are used in the help output.
269
264
  ```ruby
270
265
  module Owners
271
266
  class Add < Cl::Cmd
267
+ register :add
268
+
272
269
  summary 'Add one or more owners to an existing owner group'
273
270
 
274
271
  description <<~str
@@ -333,6 +330,8 @@ class Base < Cl::Cmd
333
330
  end
334
331
 
335
332
  class Add < Base
333
+ register :add
334
+
336
335
  def run
337
336
  puts 'Success'
338
337
  end
@@ -365,6 +364,8 @@ example the method `ownsers` will be available on the `Cmd` instance:
365
364
 
366
365
  ```ruby
367
366
  class Add < Cl::Cmd
367
+ register :add
368
+
368
369
  arg :owner
369
370
 
370
371
  def run
@@ -393,6 +394,8 @@ using this separator.
393
394
 
394
395
  ```ruby
395
396
  class Add < Cl::Cmd
397
+ register :add
398
+
396
399
  arg :owners, type: :array, sep: ','
397
400
 
398
401
  def run
@@ -412,6 +415,8 @@ Other types cast the given argument to the expected Ruby type.
412
415
 
413
416
  ```ruby
414
417
  class Cmd < Cl::Cmd
418
+ register :cmd
419
+
415
420
  arg :one, type: :integer
416
421
  arg :two, type: :float
417
422
  arg :three, type: :boolean
@@ -437,6 +442,8 @@ For example:
437
442
 
438
443
  ```ruby
439
444
  class Lft < Cl::Cmd
445
+ register :lft
446
+
440
447
  arg :a, type: :array, splat: true
441
448
  arg :b
442
449
  arg :c
@@ -447,6 +454,8 @@ class Lft < Cl::Cmd
447
454
  end
448
455
 
449
456
  class Mid < Cl::Cmd
457
+ register :mid
458
+
450
459
  arg :a
451
460
  arg :b, type: :array, splat: true
452
461
  arg :c
@@ -457,6 +466,8 @@ class Mid < Cl::Cmd
457
466
  end
458
467
 
459
468
  class Rgt < Cl::Cmd
469
+ register :rgt
470
+
460
471
  arg :a
461
472
  arg :b
462
473
  arg :c, type: :array, splat: true
@@ -498,6 +509,8 @@ For example:
498
509
 
499
510
  ```ruby
500
511
  class Add < Cl::Cmd
512
+ register :add
513
+
501
514
  opt '--to GROUP', 'Target group to add owners to'
502
515
 
503
516
  def run
@@ -532,6 +545,8 @@ the command.
532
545
 
533
546
  ```ruby
534
547
  class Add < Cl::Cmd
548
+ register :add
549
+
535
550
  # depending on its arity the block can receive:
536
551
  #
537
552
  # * value
@@ -562,6 +577,8 @@ Options can have one or many alias names, given as a Symbol or Array of Symbols:
562
577
 
563
578
  ```ruby
564
579
  class Add < Cl::Cmd
580
+ register :add
581
+
565
582
  opt '--to GROUP', alias: :group
566
583
 
567
584
  def run
@@ -586,6 +603,8 @@ I.e. this value is going to be used if the user does not provide the option:
586
603
 
587
604
  ```ruby
588
605
  class Add < Cl::Cmd
606
+ register :add
607
+
589
608
  opt '--to GROUP', default: 'default'
590
609
 
591
610
  def run
@@ -609,6 +628,8 @@ For a deprecated option:
609
628
 
610
629
  ```ruby
611
630
  class Add < Cl::Cmd
631
+ register :add
632
+
612
633
  opt '--target GROUP', deprecated: 'Deprecated.'
613
634
 
614
635
  def run
@@ -628,6 +649,8 @@ For a deprecated option alias name:
628
649
 
629
650
  ```ruby
630
651
  class Add < Cl::Cmd
652
+ register :add
653
+
631
654
  opt '--to GROUP', alias: :target, deprecated: :target
632
655
 
633
656
  def run
@@ -651,6 +674,8 @@ For example:
651
674
 
652
675
  ```ruby
653
676
  class Add < Cl::Cmd
677
+ register :add
678
+
654
679
  opt '--to GROUP', downcase: true
655
680
 
656
681
  def run
@@ -677,6 +702,8 @@ For example:
677
702
 
678
703
  ```ruby
679
704
  class Add < Cl::Cmd
705
+ register :add
706
+
680
707
  opt '--to GROUP', enum: %w(one two)
681
708
 
682
709
  def run
@@ -711,6 +738,8 @@ Options can have examples that will be printed in the help output.
711
738
 
712
739
  ```ruby
713
740
  class Add < Cl::Cmd
741
+ register :add
742
+
714
743
  opt '--to GROUP', example: 'group-one'
715
744
  end
716
745
 
@@ -738,6 +767,8 @@ For example:
738
767
 
739
768
  ```ruby
740
769
  class Add < Cl::Cmd
770
+ register :add
771
+
741
772
  opt '--to GROUP', format: /^\w+$/
742
773
 
743
774
  def run
@@ -774,6 +805,8 @@ For example:
774
805
 
775
806
  ```ruby
776
807
  class Add < Cl::Cmd
808
+ register :add
809
+
777
810
  opt '--to GROUP'
778
811
  opt '--hidden', internal: true
779
812
  end
@@ -803,6 +836,8 @@ For example:
803
836
 
804
837
  ```ruby
805
838
  class Add < Cl::Cmd
839
+ register :add
840
+
806
841
  opt '--retries COUNT', type: :integer, min: 1, max: 5
807
842
 
808
843
  def run
@@ -840,6 +875,8 @@ an option `negate` like so:
840
875
 
841
876
  ```ruby
842
877
  class Add < Cl::Cmd
878
+ register :add
879
+
843
880
  opt '--notifications', 'Send out notifications to the team', negate: %w(skip)
844
881
 
845
882
  def run
@@ -885,6 +922,8 @@ Options can have a note that will be printed in the help output.
885
922
 
886
923
  ```ruby
887
924
  class Add < Cl::Cmd
925
+ register :add
926
+
888
927
  opt '--to GROUP', note: 'needs to be a group'
889
928
  end
890
929
 
@@ -911,6 +950,8 @@ on this in order to, for example, obfuscate values from log output.
911
950
 
912
951
  ```ruby
913
952
  class Add < Cl::Cmd
953
+ register :add
954
+
914
955
  opt '--pass PASS', secret: true
915
956
 
916
957
  def run
@@ -938,6 +979,8 @@ For example:
938
979
 
939
980
  ```ruby
940
981
  class Add < Cl::Cmd
982
+ register :add
983
+
941
984
  opt '--to GROUP', see: 'https://docs.io/cli/owners/add'
942
985
  end
943
986
 
@@ -965,6 +1008,8 @@ only supports arrays of strings).
965
1008
 
966
1009
  ```ruby
967
1010
  class Add < Cl::Cmd
1011
+ register :add
1012
+
968
1013
  opt '--to GROUP', type: :array
969
1014
 
970
1015
  def run
@@ -984,6 +1029,8 @@ Other types cast the given value to the expected Ruby type.
984
1029
 
985
1030
  ```ruby
986
1031
  class Add < Cl::Cmd
1032
+ register :add
1033
+
987
1034
  opt '--active BOOL', type: :boolean
988
1035
  opt '--retries INT', type: :integer
989
1036
  opt '--sleep FLOAT', type: :float
@@ -1013,6 +1060,8 @@ For example, this simply requires the option `--to`:
1013
1060
 
1014
1061
  ```ruby
1015
1062
  class Add < Cl::Cmd
1063
+ register :add
1064
+
1016
1065
  opt '--to GROUP', required: true
1017
1066
 
1018
1067
  def run
@@ -1045,6 +1094,8 @@ This will make the option `--retries` depend on the option `--to`:
1045
1094
 
1046
1095
  ```ruby
1047
1096
  class Add < Cl::Cmd
1097
+ register :add
1098
+
1048
1099
  opt '--to GROUP'
1049
1100
  opt '--other GROUP', requires: :to
1050
1101
 
@@ -1080,6 +1131,8 @@ This requires either the option `--api_key` or both options `--username` and
1080
1131
 
1081
1132
  ```ruby
1082
1133
  class Add < Cl::Cmd
1134
+ register :add
1135
+
1083
1136
  # read DNF, i.e. "token OR user AND pass
1084
1137
  required :token, [:user, :pass]
1085
1138
 
@@ -6,6 +6,8 @@ $: << File.expand_path('lib')
6
6
 
7
7
  module Cast
8
8
  class Bool < Cl::Cmd
9
+ register :bool
10
+
9
11
  arg :bool, type: :bool
10
12
 
11
13
  def run
@@ -14,6 +16,8 @@ $: << File.expand_path('lib')
14
16
  end
15
17
 
16
18
  class Types < Cl::Cmd
19
+ register :types
20
+
17
21
  arg :a, type: :bool
18
22
  arg :b, type: :int
19
23
  arg :c, type: :float
@@ -6,6 +6,8 @@ $: << File.expand_path('lib')
6
6
 
7
7
  module Opts
8
8
  class Bool < Cl::Cmd
9
+ register :bool
10
+
9
11
  arg :bool, type: :bool
10
12
 
11
13
  def run
@@ -14,6 +16,8 @@ $: << File.expand_path('lib')
14
16
  end
15
17
 
16
18
  class Types < Cl::Cmd
19
+ register :types
20
+
17
21
  arg :a, type: :bool
18
22
  arg :b, type: :int
19
23
  arg :c, type: :float
@@ -5,6 +5,8 @@ $: << File.expand_path('lib')
5
5
  require 'cl'
6
6
 
7
7
  class Required < Cl::Cmd
8
+ register :required
9
+
8
10
  arg :one, required: true
9
11
  arg :two
10
12
 
@@ -8,6 +8,8 @@ $: << File.expand_path('lib')
8
8
  module Release
9
9
  module Cmds
10
10
  class Release < Cl::Cmd
11
+ register 'release'
12
+
11
13
  arg :gemspec
12
14
 
13
15
  opt '-h', '--host HOST', 'Push to a compatible host other than rubygems.org'
@@ -20,6 +22,8 @@ $: << File.expand_path('lib')
20
22
  end
21
23
 
22
24
  class Bump < Cl::Cmd
25
+ register 'bump'
26
+
23
27
  opt '-v', '--version VERSION', 'The version to bump to [1.1.1|major|minor|patch|pre|rc|release]'
24
28
  opt '--[no-]commit', 'Bump the version, but do not commit'
25
29
 
@@ -9,6 +9,8 @@ require 'cl'
9
9
  end
10
10
 
11
11
  class Add < Base
12
+ register :add
13
+
12
14
  def run
13
15
  puts 'Success'
14
16
  end
@@ -5,6 +5,8 @@ $: << File.expand_path('lib')
5
5
  require 'cl'
6
6
 
7
7
  class Add < Cl::Cmd
8
+ register :add
9
+
8
10
  opt '--to GROUP', alias: :group
9
11
 
10
12
  def run
@@ -5,6 +5,8 @@ $: << File.expand_path('lib')
5
5
  require 'cl'
6
6
 
7
7
  class Add < Cl::Cmd
8
+ register :add
9
+
8
10
  arg :owner
9
11
 
10
12
  def run
@@ -5,6 +5,8 @@ $: << File.expand_path('lib')
5
5
  require 'cl'
6
6
 
7
7
  class Add < Cl::Cmd
8
+ register :add
9
+
8
10
  arg :owners, type: :array, sep: ','
9
11
 
10
12
  def run
@@ -5,6 +5,8 @@ $: << File.expand_path('lib')
5
5
  require 'cl'
6
6
 
7
7
  class Cmd < Cl::Cmd
8
+ register :cmd
9
+
8
10
  arg :one, type: :integer
9
11
  arg :two, type: :float
10
12
  arg :three, type: :boolean
@@ -5,6 +5,8 @@ $: << File.expand_path('lib')
5
5
  require 'cl'
6
6
 
7
7
  class Lft < Cl::Cmd
8
+ register :lft
9
+
8
10
  arg :a, type: :array, splat: true
9
11
  arg :b
10
12
  arg :c
@@ -15,6 +17,8 @@ $: << File.expand_path('lib')
15
17
  end
16
18
 
17
19
  class Mid < Cl::Cmd
20
+ register :mid
21
+
18
22
  arg :a
19
23
  arg :b, type: :array, splat: true
20
24
  arg :c
@@ -25,6 +29,8 @@ $: << File.expand_path('lib')
25
29
  end
26
30
 
27
31
  class Rgt < Cl::Cmd
32
+ register :rgt
33
+
28
34
  arg :a
29
35
  arg :b
30
36
  arg :c, type: :array, splat: true
@@ -5,6 +5,8 @@ $: << File.expand_path('lib')
5
5
  require 'cl'
6
6
 
7
7
  class Add < Cl::Cmd
8
+ register :add
9
+
8
10
  opt '--to GROUP', type: :array
9
11
 
10
12
  def run
@@ -4,6 +4,8 @@
4
4
  # e.g. lib/owners/add.rb
5
5
  module Owners
6
6
  class Add < Cl::Cmd
7
+ register :add
8
+
7
9
  summary 'Add one or more owners to an existing owner group'
8
10
 
9
11
  description <<~str
@@ -5,6 +5,8 @@ $: << File.expand_path('lib')
5
5
  require 'cl'
6
6
 
7
7
  class Add < Cl::Cmd
8
+ register :add
9
+
8
10
  opt '--to GROUP', default: 'default'
9
11
 
10
12
  def run
@@ -5,6 +5,8 @@ $: << File.expand_path('lib')
5
5
  require 'cl'
6
6
 
7
7
  class Add < Cl::Cmd
8
+ register :add
9
+
8
10
  opt '--target GROUP', deprecated: 'Deprecated.'
9
11
 
10
12
  def run
@@ -5,6 +5,8 @@ $: << File.expand_path('lib')
5
5
  require 'cl'
6
6
 
7
7
  class Add < Cl::Cmd
8
+ register :add
9
+
8
10
  opt '--to GROUP', alias: :target, deprecated: :target
9
11
 
10
12
  def run
@@ -6,6 +6,8 @@ $: << File.expand_path('lib')
6
6
 
7
7
  module Owners
8
8
  class Add < Cl::Cmd
9
+ register :add
10
+
9
11
  summary 'Add one or more owners to an existing owner group'
10
12
 
11
13
  description <<~str
@@ -5,6 +5,8 @@ $: << File.expand_path('lib')
5
5
  require 'cl'
6
6
 
7
7
  class Add < Cl::Cmd
8
+ register :add
9
+
8
10
  opt '--to GROUP', downcase: true
9
11
 
10
12
  def run
@@ -5,6 +5,8 @@ $: << File.expand_path('lib')
5
5
  require 'cl'
6
6
 
7
7
  class Add < Cl::Cmd
8
+ register :add
9
+
8
10
  opt '--to GROUP', enum: %w(one two)
9
11
 
10
12
  def run
@@ -5,6 +5,8 @@ $: << File.expand_path('lib')
5
5
  require 'cl'
6
6
 
7
7
  class Add < Cl::Cmd
8
+ register :add
9
+
8
10
  opt '--to GROUP', example: 'group-one'
9
11
  end
10
12
  rb
@@ -5,6 +5,8 @@ $: << File.expand_path('lib')
5
5
  require 'cl'
6
6
 
7
7
  class Add < Cl::Cmd
8
+ register :add
9
+
8
10
  opt '--to GROUP', format: /^\w+$/
9
11
 
10
12
  def run
@@ -7,6 +7,8 @@ require 'cl'
7
7
  require 'cl'
8
8
 
9
9
  class Add < Cl::Cmd
10
+ register :add
11
+
10
12
  opt '--to GROUP'
11
13
  opt '--hidden', internal: true
12
14
  end
@@ -5,6 +5,8 @@ $: << File.expand_path('lib')
5
5
  require 'cl'
6
6
 
7
7
  class Add < Cl::Cmd
8
+ register :add
9
+
8
10
  opt '--notifications', 'Send out notifications to the team', negate: %w(skip)
9
11
 
10
12
  def run
@@ -5,6 +5,8 @@ $: << File.expand_path('lib')
5
5
  require 'cl'
6
6
 
7
7
  class Add < Cl::Cmd
8
+ register :add
9
+
8
10
  opt '--to GROUP', note: 'needs to be a group'
9
11
  end
10
12
  rb
@@ -5,6 +5,8 @@ $: << File.expand_path('lib')
5
5
  require 'cl'
6
6
 
7
7
  class Add < Cl::Cmd
8
+ register :add
9
+
8
10
  opt '--to GROUP', 'Target group to add owners to'
9
11
 
10
12
  def run
@@ -5,6 +5,8 @@ $: << File.expand_path('lib')
5
5
  require 'cl'
6
6
 
7
7
  class Add < Cl::Cmd
8
+ register :add
9
+
8
10
  # depending on its arity the block can receive:
9
11
  #
10
12
  # * value
@@ -5,6 +5,8 @@ $: << File.expand_path('lib')
5
5
  require 'cl'
6
6
 
7
7
  class Add < Cl::Cmd
8
+ register :add
9
+
8
10
  opt '--retries COUNT', type: :integer, min: 1, max: 5
9
11
 
10
12
  def run
@@ -4,9 +4,11 @@ $: << File.expand_path('lib')
4
4
  <%= run sq(<<-'rb')
5
5
  module Cmd
6
6
  class One < Cl::Cmd
7
+ register :one
7
8
  end
8
9
 
9
10
  class Two < Cl::Cmd
11
+ register :two
10
12
  end
11
13
  end
12
14
  rb
@@ -5,6 +5,8 @@ $: << File.expand_path('lib')
5
5
  require 'cl'
6
6
 
7
7
  class Add < Cl::Cmd
8
+ register :add
9
+
8
10
  opt '--to GROUP', required: true
9
11
 
10
12
  def run
@@ -3,6 +3,8 @@ $: << File.expand_path('lib')
3
3
 
4
4
  <%= run sq(<<-'rb')
5
5
  class Add < Cl::Cmd
6
+ register :add
7
+
6
8
  # read DNF, i.e. "token OR user AND pass
7
9
  required :token, [:user, :pass]
8
10
 
@@ -3,6 +3,8 @@ $: << File.expand_path('lib')
3
3
 
4
4
  <%= run sq(<<-'rb')
5
5
  class Add < Cl::Cmd
6
+ register :add
7
+
6
8
  opt '--to GROUP'
7
9
  opt '--other GROUP', requires: :to
8
10
 
@@ -3,6 +3,8 @@ $: << File.expand_path('lib')
3
3
 
4
4
  <%= run sq(<<-'rb')
5
5
  class Add < Cl::Cmd
6
+ register :add
7
+
6
8
  opt '--pass PASS', secret: true
7
9
 
8
10
  def run
@@ -5,6 +5,8 @@ $: << File.expand_path('lib')
5
5
  require 'cl'
6
6
 
7
7
  class Add < Cl::Cmd
8
+ register :add
9
+
8
10
  opt '--to GROUP', see: 'https://docs.io/cli/owners/add'
9
11
  end
10
12
  rb
@@ -3,6 +3,8 @@ $: << File.expand_path('lib')
3
3
 
4
4
  <%= run sq(<<-'rb')
5
5
  class Add < Cl::Cmd
6
+ register :add
7
+
6
8
  opt '--active BOOL', type: :boolean
7
9
  opt '--retries INT', type: :integer
8
10
  opt '--sleep FLOAT', type: :float
@@ -5,6 +5,8 @@ require 'cl'
5
5
 
6
6
  module Cast
7
7
  class Bool < Cl::Cmd
8
+ register :bool
9
+
8
10
  arg :bool, type: :bool
9
11
 
10
12
  def run
@@ -13,6 +15,8 @@ module Cast
13
15
  end
14
16
 
15
17
  class Types < Cl::Cmd
18
+ register :types
19
+
16
20
  arg :a, type: :bool
17
21
  arg :b, type: :int
18
22
  arg :c, type: :float
@@ -5,6 +5,8 @@ require 'cl'
5
5
 
6
6
  module Opts
7
7
  class Bool < Cl::Cmd
8
+ register :bool
9
+
8
10
  arg :bool, type: :bool
9
11
 
10
12
  def run
@@ -13,6 +15,8 @@ module Opts
13
15
  end
14
16
 
15
17
  class Types < Cl::Cmd
18
+ register :types
19
+
16
20
  arg :a, type: :bool
17
21
  arg :b, type: :int
18
22
  arg :c, type: :float
@@ -4,6 +4,8 @@ $: << File.expand_path('lib')
4
4
  require 'cl'
5
5
 
6
6
  class Required < Cl::Cmd
7
+ register :required
8
+
7
9
  arg :one, required: true
8
10
  arg :two
9
11
 
@@ -7,6 +7,8 @@ module Gem
7
7
  module Release
8
8
  module Cmds
9
9
  class Release < Cl::Cmd
10
+ register 'release'
11
+
10
12
  arg :gemspec
11
13
 
12
14
  opt '-h', '--host HOST', 'Push to a compatible host other than rubygems.org'
@@ -19,6 +21,8 @@ module Gem
19
21
  end
20
22
 
21
23
  class Bump < Cl::Cmd
24
+ register 'bump'
25
+
22
26
  opt '-v', '--version VERSION', 'The version to bump to [1.1.1|major|minor|patch|pre|rc|release]'
23
27
  opt '--[no-]commit', 'Bump the version, but do not commit'
24
28
 
@@ -8,6 +8,8 @@ class Base < Cl::Cmd
8
8
  end
9
9
 
10
10
  class Add < Base
11
+ register :add
12
+
11
13
  def run
12
14
  puts 'Success'
13
15
  end
@@ -4,6 +4,8 @@ $: << File.expand_path('lib')
4
4
  require 'cl'
5
5
 
6
6
  class Add < Cl::Cmd
7
+ register :add
8
+
7
9
  opt '--to GROUP', alias: :group
8
10
 
9
11
  def run
@@ -4,6 +4,8 @@ $: << File.expand_path('lib')
4
4
  require 'cl'
5
5
 
6
6
  class Add < Cl::Cmd
7
+ register :add
8
+
7
9
  arg :owner
8
10
 
9
11
  def run
@@ -4,6 +4,8 @@ $: << File.expand_path('lib')
4
4
  require 'cl'
5
5
 
6
6
  class Add < Cl::Cmd
7
+ register :add
8
+
7
9
  arg :owners, type: :array, sep: ','
8
10
 
9
11
  def run
@@ -4,6 +4,8 @@ $: << File.expand_path('lib')
4
4
  require 'cl'
5
5
 
6
6
  class Cmd < Cl::Cmd
7
+ register :cmd
8
+
7
9
  arg :one, type: :integer
8
10
  arg :two, type: :float
9
11
  arg :three, type: :boolean
@@ -4,6 +4,8 @@ $: << File.expand_path('lib')
4
4
  require 'cl'
5
5
 
6
6
  class Lft < Cl::Cmd
7
+ register :lft
8
+
7
9
  arg :a, type: :array, splat: true
8
10
  arg :b
9
11
  arg :c
@@ -14,6 +16,8 @@ class Lft < Cl::Cmd
14
16
  end
15
17
 
16
18
  class Mid < Cl::Cmd
19
+ register :mid
20
+
17
21
  arg :a
18
22
  arg :b, type: :array, splat: true
19
23
  arg :c
@@ -24,6 +28,8 @@ class Mid < Cl::Cmd
24
28
  end
25
29
 
26
30
  class Rgt < Cl::Cmd
31
+ register :rgt
32
+
27
33
  arg :a
28
34
  arg :b
29
35
  arg :c, type: :array, splat: true
@@ -4,6 +4,8 @@ $: << File.expand_path('lib')
4
4
  require 'cl'
5
5
 
6
6
  class Add < Cl::Cmd
7
+ register :add
8
+
7
9
  opt '--to GROUP', type: :array
8
10
 
9
11
  def run
@@ -3,6 +3,8 @@ require 'cl'
3
3
  # e.g. lib/owners/add.rb
4
4
  module Owners
5
5
  class Add < Cl::Cmd
6
+ register :add
7
+
6
8
  summary 'Add one or more owners to an existing owner group'
7
9
 
8
10
  description <<~str
@@ -4,6 +4,8 @@ $: << File.expand_path('lib')
4
4
  require 'cl'
5
5
 
6
6
  class Add < Cl::Cmd
7
+ register :add
8
+
7
9
  opt '--to GROUP', default: 'default'
8
10
 
9
11
  def run
@@ -4,6 +4,8 @@ $: << File.expand_path('lib')
4
4
  require 'cl'
5
5
 
6
6
  class Add < Cl::Cmd
7
+ register :add
8
+
7
9
  opt '--target GROUP', deprecated: 'Deprecated.'
8
10
 
9
11
  def run
@@ -4,6 +4,8 @@ $: << File.expand_path('lib')
4
4
  require 'cl'
5
5
 
6
6
  class Add < Cl::Cmd
7
+ register :add
8
+
7
9
  opt '--to GROUP', alias: :target, deprecated: :target
8
10
 
9
11
  def run
@@ -5,6 +5,8 @@ require 'cl'
5
5
 
6
6
  module Owners
7
7
  class Add < Cl::Cmd
8
+ register :add
9
+
8
10
  summary 'Add one or more owners to an existing owner group'
9
11
 
10
12
  description <<~str
@@ -4,6 +4,8 @@ $: << File.expand_path('lib')
4
4
  require 'cl'
5
5
 
6
6
  class Add < Cl::Cmd
7
+ register :add
8
+
7
9
  opt '--to GROUP', downcase: true
8
10
 
9
11
  def run
@@ -4,6 +4,8 @@ $: << File.expand_path('lib')
4
4
  require 'cl'
5
5
 
6
6
  class Add < Cl::Cmd
7
+ register :add
8
+
7
9
  opt '--to GROUP', enum: %w(one two)
8
10
 
9
11
  def run
@@ -4,6 +4,8 @@ $: << File.expand_path('lib')
4
4
  require 'cl'
5
5
 
6
6
  class Add < Cl::Cmd
7
+ register :add
8
+
7
9
  opt '--to GROUP', example: 'group-one'
8
10
  end
9
11
 
@@ -4,6 +4,8 @@ $: << File.expand_path('lib')
4
4
  require 'cl'
5
5
 
6
6
  class Add < Cl::Cmd
7
+ register :add
8
+
7
9
  opt '--to GROUP', format: /^\w+$/
8
10
 
9
11
  def run
@@ -6,6 +6,8 @@ require 'cl'
6
6
  require 'cl'
7
7
 
8
8
  class Add < Cl::Cmd
9
+ register :add
10
+
9
11
  opt '--to GROUP'
10
12
  opt '--hidden', internal: true
11
13
  end
@@ -4,6 +4,8 @@ $: << File.expand_path('lib')
4
4
  require 'cl'
5
5
 
6
6
  class Add < Cl::Cmd
7
+ register :add
8
+
7
9
  opt '--notifications', 'Send out notifications to the team', negate: %w(skip)
8
10
 
9
11
  def run
@@ -4,6 +4,8 @@ $: << File.expand_path('lib')
4
4
  require 'cl'
5
5
 
6
6
  class Add < Cl::Cmd
7
+ register :add
8
+
7
9
  opt '--to GROUP', note: 'needs to be a group'
8
10
  end
9
11
 
@@ -4,6 +4,8 @@ $: << File.expand_path('lib')
4
4
  require 'cl'
5
5
 
6
6
  class Add < Cl::Cmd
7
+ register :add
8
+
7
9
  opt '--to GROUP', 'Target group to add owners to'
8
10
 
9
11
  def run
@@ -4,6 +4,8 @@ $: << File.expand_path('lib')
4
4
  require 'cl'
5
5
 
6
6
  class Add < Cl::Cmd
7
+ register :add
8
+
7
9
  # depending on its arity the block can receive:
8
10
  #
9
11
  # * value
@@ -4,6 +4,8 @@ $: << File.expand_path('lib')
4
4
  require 'cl'
5
5
 
6
6
  class Add < Cl::Cmd
7
+ register :add
8
+
7
9
  opt '--retries COUNT', type: :integer, min: 1, max: 5
8
10
 
9
11
  def run
@@ -3,9 +3,11 @@ $: << File.expand_path('lib')
3
3
 
4
4
  module Cmd
5
5
  class One < Cl::Cmd
6
+ register :one
6
7
  end
7
8
 
8
9
  class Two < Cl::Cmd
10
+ register :two
9
11
  end
10
12
  end
11
13
 
@@ -4,6 +4,8 @@ $: << File.expand_path('lib')
4
4
  require 'cl'
5
5
 
6
6
  class Add < Cl::Cmd
7
+ register :add
8
+
7
9
  opt '--to GROUP', required: true
8
10
 
9
11
  def run
@@ -2,6 +2,8 @@
2
2
  $: << File.expand_path('lib')
3
3
 
4
4
  class Add < Cl::Cmd
5
+ register :add
6
+
5
7
  # read DNF, i.e. "token OR user AND pass
6
8
  required :token, [:user, :pass]
7
9
 
@@ -2,6 +2,8 @@
2
2
  $: << File.expand_path('lib')
3
3
 
4
4
  class Add < Cl::Cmd
5
+ register :add
6
+
5
7
  opt '--to GROUP'
6
8
  opt '--other GROUP', requires: :to
7
9
 
@@ -2,6 +2,8 @@
2
2
  $: << File.expand_path('lib')
3
3
 
4
4
  class Add < Cl::Cmd
5
+ register :add
6
+
5
7
  opt '--pass PASS', secret: true
6
8
 
7
9
  def run
@@ -4,6 +4,8 @@ $: << File.expand_path('lib')
4
4
  require 'cl'
5
5
 
6
6
  class Add < Cl::Cmd
7
+ register :add
8
+
7
9
  opt '--to GROUP', see: 'https://docs.io/cli/owners/add'
8
10
  end
9
11
 
@@ -2,6 +2,8 @@
2
2
  $: << File.expand_path('lib')
3
3
 
4
4
  class Add < Cl::Cmd
5
+ register :add
6
+
5
7
  opt '--active BOOL', type: :boolean
6
8
  opt '--retries INT', type: :integer
7
9
  opt '--sleep FLOAT', type: :float
@@ -7,6 +7,7 @@ require 'cl/parser'
7
7
 
8
8
  class Cl
9
9
  singleton_class.send(:attr_accessor, :auto_register) # remove unless anyone needs this
10
+ singleton_class.instance_variable_set(:@auto_register, true)
10
11
 
11
12
  # Base class for all command classes that can be run.
12
13
  #
@@ -23,7 +24,7 @@ class Cl
23
24
  include Merge, Suggest, Underscore
24
25
 
25
26
  inherited = ->(const) do
26
- return unless Cl.auto_register
27
+ # return unless Cl.auto_register
27
28
  if const.name
28
29
  key = underscore(const.name.split('::').last)
29
30
  key = [registry_key, key].compact.join(':') unless abstract?
@@ -1,3 +1,3 @@
1
1
  class Cl
2
- VERSION = '1.2.2'
2
+ VERSION = '1.2.3'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cl
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.2
4
+ version: 1.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sven Fuchs