travis-cl 1.2.4

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.
Files changed (114) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +134 -0
  3. data/Gemfile +11 -0
  4. data/Gemfile.lock +59 -0
  5. data/MIT_LICENSE.md +21 -0
  6. data/README.md +1283 -0
  7. data/cl.gemspec +30 -0
  8. data/examples/README.md +22 -0
  9. data/examples/_src/args/cast.erb.rb +100 -0
  10. data/examples/_src/args/opts.erb.rb +100 -0
  11. data/examples/_src/args/required.erb.rb +63 -0
  12. data/examples/_src/args/splat.erb.rb +55 -0
  13. data/examples/_src/gem.erb.rb +99 -0
  14. data/examples/_src/heroku.erb.rb +47 -0
  15. data/examples/_src/rakeish.erb.rb +54 -0
  16. data/examples/_src/readme/abstract.erb.rb +27 -0
  17. data/examples/_src/readme/alias.erb.rb +22 -0
  18. data/examples/_src/readme/arg.erb.rb +21 -0
  19. data/examples/_src/readme/arg_array.erb.rb +21 -0
  20. data/examples/_src/readme/arg_type.erb.rb +23 -0
  21. data/examples/_src/readme/args_splat.erb.rb +55 -0
  22. data/examples/_src/readme/array.erb.rb +21 -0
  23. data/examples/_src/readme/basic.erb.rb +72 -0
  24. data/examples/_src/readme/default.erb.rb +21 -0
  25. data/examples/_src/readme/deprecated.erb.rb +21 -0
  26. data/examples/_src/readme/deprecated_alias.erb.rb +21 -0
  27. data/examples/_src/readme/description.erb.rb +60 -0
  28. data/examples/_src/readme/downcase.erb.rb +21 -0
  29. data/examples/_src/readme/enum.erb.rb +35 -0
  30. data/examples/_src/readme/example.erb.rb +25 -0
  31. data/examples/_src/readme/format.erb.rb +35 -0
  32. data/examples/_src/readme/internal.erb.rb +28 -0
  33. data/examples/_src/readme/negate.erb.rb +37 -0
  34. data/examples/_src/readme/note.erb.rb +25 -0
  35. data/examples/_src/readme/opts.erb.rb +33 -0
  36. data/examples/_src/readme/opts_block.erb.rb +30 -0
  37. data/examples/_src/readme/range.erb.rb +35 -0
  38. data/examples/_src/readme/registry.erb.rb +18 -0
  39. data/examples/_src/readme/required.erb.rb +35 -0
  40. data/examples/_src/readme/requireds.erb.rb +46 -0
  41. data/examples/_src/readme/requires.erb.rb +35 -0
  42. data/examples/_src/readme/runner.erb.rb +29 -0
  43. data/examples/_src/readme/runner_custom.erb.rb +25 -0
  44. data/examples/_src/readme/secret.erb.rb +22 -0
  45. data/examples/_src/readme/see.erb.rb +25 -0
  46. data/examples/_src/readme/type.erb.rb +21 -0
  47. data/examples/args/cast +98 -0
  48. data/examples/args/opts +98 -0
  49. data/examples/args/required +62 -0
  50. data/examples/args/splat +58 -0
  51. data/examples/gem +97 -0
  52. data/examples/heroku +48 -0
  53. data/examples/rakeish +50 -0
  54. data/examples/readme/abstract +28 -0
  55. data/examples/readme/alias +21 -0
  56. data/examples/readme/arg +20 -0
  57. data/examples/readme/arg_array +20 -0
  58. data/examples/readme/arg_type +22 -0
  59. data/examples/readme/args_splat +58 -0
  60. data/examples/readme/array +20 -0
  61. data/examples/readme/basic +67 -0
  62. data/examples/readme/default +20 -0
  63. data/examples/readme/deprecated +20 -0
  64. data/examples/readme/deprecated_alias +20 -0
  65. data/examples/readme/description +56 -0
  66. data/examples/readme/downcase +20 -0
  67. data/examples/readme/enum +33 -0
  68. data/examples/readme/example +21 -0
  69. data/examples/readme/format +33 -0
  70. data/examples/readme/internal +24 -0
  71. data/examples/readme/negate +44 -0
  72. data/examples/readme/note +21 -0
  73. data/examples/readme/opts +31 -0
  74. data/examples/readme/opts_block +29 -0
  75. data/examples/readme/range +33 -0
  76. data/examples/readme/registry +15 -0
  77. data/examples/readme/required +33 -0
  78. data/examples/readme/requireds +46 -0
  79. data/examples/readme/requires +33 -0
  80. data/examples/readme/runner +30 -0
  81. data/examples/readme/runner_custom +22 -0
  82. data/examples/readme/secret +21 -0
  83. data/examples/readme/see +21 -0
  84. data/examples/readme/type +20 -0
  85. data/lib/cl/arg.rb +79 -0
  86. data/lib/cl/args.rb +92 -0
  87. data/lib/cl/cast.rb +55 -0
  88. data/lib/cl/cmd.rb +74 -0
  89. data/lib/cl/config/env.rb +52 -0
  90. data/lib/cl/config/files.rb +34 -0
  91. data/lib/cl/config.rb +30 -0
  92. data/lib/cl/ctx.rb +36 -0
  93. data/lib/cl/dsl.rb +182 -0
  94. data/lib/cl/errors.rb +119 -0
  95. data/lib/cl/help/cmd.rb +118 -0
  96. data/lib/cl/help/cmds.rb +26 -0
  97. data/lib/cl/help/format.rb +69 -0
  98. data/lib/cl/help/table.rb +58 -0
  99. data/lib/cl/help/usage.rb +26 -0
  100. data/lib/cl/help.rb +37 -0
  101. data/lib/cl/helper/suggest.rb +10 -0
  102. data/lib/cl/helper.rb +47 -0
  103. data/lib/cl/opt.rb +276 -0
  104. data/lib/cl/opts/validate.rb +117 -0
  105. data/lib/cl/opts.rb +114 -0
  106. data/lib/cl/parser/format.rb +63 -0
  107. data/lib/cl/parser.rb +70 -0
  108. data/lib/cl/runner/default.rb +86 -0
  109. data/lib/cl/runner/multi.rb +34 -0
  110. data/lib/cl/runner.rb +10 -0
  111. data/lib/cl/ui.rb +146 -0
  112. data/lib/cl/version.rb +3 -0
  113. data/lib/cl.rb +62 -0
  114. metadata +177 -0
@@ -0,0 +1,35 @@
1
+ #!/usr/bin/env ruby
2
+ $: << File.expand_path('lib')
3
+
4
+ <%= run sq(<<-'rb')
5
+ class Add < Cl::Cmd
6
+ register :add
7
+
8
+ opt '--to GROUP'
9
+ opt '--other GROUP', requires: :to
10
+
11
+ def run
12
+ p to: to, other: other
13
+ end
14
+ end
15
+ rb
16
+ -%>
17
+
18
+ <%= run "Cl.new('owners').run(%w(add --to one --other two))" %>
19
+
20
+ <%= out '{:to=>"one", :other=>"two"}' %>
21
+
22
+ <%= run "Cl.new('owners').run(%w(add --other two))" %>
23
+
24
+ <%= out sq(<<-'str')
25
+ Missing option: to (required by other)
26
+
27
+ Usage: owners add [options]
28
+
29
+ Options:
30
+
31
+ --to GROUP type: string
32
+ --other GROUP type: string, requires: to
33
+ --help Get help on this command
34
+ str
35
+ %>
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ $: << File.expand_path('lib')
3
+
4
+ <%= run sq(<<-'rb')
5
+ module Git
6
+ class Pull < Cl::Cmd
7
+ register :'git:pull'
8
+
9
+ arg :branch
10
+
11
+ def run
12
+ p cmd: registry_key, args: args
13
+ end
14
+ end
15
+ end
16
+ rb
17
+ -%>
18
+
19
+ # With this class registered (and assuming the executable that calls `Cl` is
20
+ # `bin/run`) the default runner would recognize and run it:
21
+ #
22
+ # $ bin/run git:pull master # instantiates Git::Pull, and passes ["master"] as args
23
+ # $ bin/run git pull master # does the same
24
+
25
+ <%= run "Cl.new('run').run(%w(git:pull master))" %>
26
+ <%= out '{:cmd=>:"git:pull", :args=>["master"]}' %>
27
+
28
+ <%= run "Cl.new('run').run(%w(git pull master))" %>
29
+ <%= out '{:cmd=>:"git:pull", :args=>["master"]}' %>
@@ -0,0 +1,25 @@
1
+ <%= run sq(<<-'rb')
2
+ # anywhere in your library
3
+
4
+ require 'cl'
5
+
6
+ class Runner
7
+ Cl::Runner.register :custom, self
8
+
9
+ def initialize(ctx, args)
10
+ # ...
11
+ end
12
+
13
+ def run
14
+ const = identify_cmd_class_from_args
15
+ const.new(ctx, args).run
16
+ end
17
+ end
18
+ rb
19
+ -%>
20
+
21
+ # in bin/run
22
+ Cl.new('run', runner: :custom).run(ARGV)
23
+
24
+ <% run "p Cl.new('run', runner: :custom).runner([]).class" %>
25
+ <% out 'Runner' %>
@@ -0,0 +1,22 @@
1
+ #!/usr/bin/env ruby
2
+ $: << File.expand_path('lib')
3
+
4
+ <%= run sq(<<-'rb')
5
+ class Add < Cl::Cmd
6
+ register :add
7
+
8
+ opt '--pass PASS', secret: true
9
+
10
+ def run
11
+ p(
12
+ secret?: self.class.opts[:pass].secret?,
13
+ tainted?: pass
14
+ )
15
+ end
16
+ end
17
+ rb
18
+ -%>
19
+
20
+ <%= run "Cl.new('owners').run(%w(add --pass pass))" %>
21
+
22
+ <%= out '{:secret?=>true, :tainted?=>true}' %>
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env ruby
2
+ $: << File.expand_path('lib')
3
+
4
+ <%= run sq(<<-'rb')
5
+ require 'cl'
6
+
7
+ class Add < Cl::Cmd
8
+ register :add
9
+
10
+ opt '--to GROUP', see: 'https://docs.io/cli/owners/add'
11
+ end
12
+ rb
13
+ -%>
14
+
15
+ <%= run "Cl.new('owners').run(%w(add --help))" %>
16
+
17
+ <%= out sq(<<-'str')
18
+ Usage: owners add [options]
19
+
20
+ Options:
21
+
22
+ --to GROUP type: string, see: https://docs.io/cli/owners/add
23
+ --help Get help on this command
24
+ str
25
+ %>
@@ -0,0 +1,21 @@
1
+ #!/usr/bin/env ruby
2
+ $: << File.expand_path('lib')
3
+
4
+ <%= run sq(<<-'rb')
5
+ class Add < Cl::Cmd
6
+ register :add
7
+
8
+ opt '--active BOOL', type: :boolean
9
+ opt '--retries INT', type: :integer
10
+ opt '--sleep FLOAT', type: :float
11
+
12
+ def run
13
+ p active: active.class, retries: retries.class, sleep: sleep.class
14
+ end
15
+ end
16
+ rb
17
+ -%>
18
+
19
+ <%= run "Cl.new('owners').run(%w(add --active yes --retries 1 --sleep 0.1))" %>
20
+
21
+ <%= out "{:active=>TrueClass, :retries=>#{RUBY_VERSION < '2.4' ? 'Fixnum' : 'Integer'}, :sleep=>Float}" %>
@@ -0,0 +1,98 @@
1
+ #!/usr/bin/env ruby
2
+ $: << File.expand_path('lib')
3
+
4
+ require 'cl'
5
+
6
+ module Cast
7
+ class Bool < Cl::Cmd
8
+ register :bool
9
+
10
+ arg :bool, type: :bool
11
+
12
+ def run
13
+ p cmd: registry_key, bool: bool
14
+ end
15
+ end
16
+
17
+ class Types < Cl::Cmd
18
+ register :types
19
+
20
+ arg :a, type: :bool
21
+ arg :b, type: :int
22
+ arg :c, type: :float
23
+ arg :d
24
+
25
+ def run
26
+ p cmd: registry_key, a: a, b: b, c: c, d: d
27
+ end
28
+ end
29
+ end
30
+
31
+ Cl.new($0).run(%w(bool on))
32
+
33
+ # Output:
34
+ #
35
+ # {:cmd=>:bool, :bool=>true}
36
+
37
+ Cl.new($0).run(%w(types true 1 1.2 foo))
38
+
39
+ # Output:
40
+ #
41
+ # {:cmd=>:types, :a=>true, :b=>1, :c=>1.2, :d=>"foo"}
42
+
43
+ Cl.new($0).run(%w(types true 1 1.2 foo bar))
44
+
45
+ # Output:
46
+ #
47
+ # Too many arguments: true 1 1.2 foo bar (given: 5, allowed: 4)
48
+ #
49
+ # Usage: bin/examples types [a:bool] [b:int] [c:float] [d] [options]
50
+ #
51
+ # Arguments:
52
+ #
53
+ # a type: bool
54
+ # b type: int
55
+ # c type: float
56
+ # d type: string
57
+ #
58
+ # Options:
59
+ #
60
+ # --help Get help on this command
61
+
62
+ Cl.new($0).run(%w(types true one 1.2))
63
+
64
+ # Output:
65
+ #
66
+ # Wrong argument type (given: "one", expected: int)
67
+ #
68
+ # Usage: bin/examples types [a:bool] [b:int] [c:float] [d] [options]
69
+ #
70
+ # Arguments:
71
+ #
72
+ # a type: bool
73
+ # b type: int
74
+ # c type: float
75
+ # d type: string
76
+ #
77
+ # Options:
78
+ #
79
+ # --help Get help on this command
80
+
81
+ Cl.new($0).run(%w(types true 1 one))
82
+
83
+ # Output:
84
+ #
85
+ # Wrong argument type (given: "one", expected: float)
86
+ #
87
+ # Usage: bin/examples types [a:bool] [b:int] [c:float] [d] [options]
88
+ #
89
+ # Arguments:
90
+ #
91
+ # a type: bool
92
+ # b type: int
93
+ # c type: float
94
+ # d type: string
95
+ #
96
+ # Options:
97
+ #
98
+ # --help Get help on this command
@@ -0,0 +1,98 @@
1
+ #!/usr/bin/env ruby
2
+ $: << File.expand_path('lib')
3
+
4
+ require 'cl'
5
+
6
+ module Opts
7
+ class Bool < Cl::Cmd
8
+ register :bool
9
+
10
+ arg :bool, type: :bool
11
+
12
+ def run
13
+ p cmd: registry_key, bool: bool
14
+ end
15
+ end
16
+
17
+ class Types < Cl::Cmd
18
+ register :types
19
+
20
+ arg :a, type: :bool
21
+ arg :b, type: :int
22
+ arg :c, type: :float
23
+ arg :d
24
+
25
+ def run
26
+ p cmd: registry_key, a: a, b: b, c: c, d: d
27
+ end
28
+ end
29
+ end
30
+
31
+ Cl.new($0).run(%w(bool on))
32
+
33
+ # Output:
34
+ #
35
+ # {:cmd=>:bool, :bool=>true}
36
+
37
+ Cl.new($0).run(%w(types true 1 1.2 foo))
38
+
39
+ # Output:
40
+ #
41
+ # {:cmd=>:types, :a=>true, :b=>1, :c=>1.2, :d=>"foo"}
42
+
43
+ Cl.new($0).run(%w(types true 1 1.2 foo bar))
44
+
45
+ # Output:
46
+ #
47
+ # Too many arguments: true 1 1.2 foo bar (given: 5, allowed: 4)
48
+ #
49
+ # Usage: bin/examples types [a:bool] [b:int] [c:float] [d] [options]
50
+ #
51
+ # Arguments:
52
+ #
53
+ # a type: bool
54
+ # b type: int
55
+ # c type: float
56
+ # d type: string
57
+ #
58
+ # Options:
59
+ #
60
+ # --help Get help on this command
61
+
62
+ Cl.new($0).run(%w(types true one 1.2))
63
+
64
+ # Output:
65
+ #
66
+ # Wrong argument type (given: "one", expected: int)
67
+ #
68
+ # Usage: bin/examples types [a:bool] [b:int] [c:float] [d] [options]
69
+ #
70
+ # Arguments:
71
+ #
72
+ # a type: bool
73
+ # b type: int
74
+ # c type: float
75
+ # d type: string
76
+ #
77
+ # Options:
78
+ #
79
+ # --help Get help on this command
80
+
81
+ Cl.new($0).run(%w(types true 1 one))
82
+
83
+ # Output:
84
+ #
85
+ # Wrong argument type (given: "one", expected: float)
86
+ #
87
+ # Usage: bin/examples types [a:bool] [b:int] [c:float] [d] [options]
88
+ #
89
+ # Arguments:
90
+ #
91
+ # a type: bool
92
+ # b type: int
93
+ # c type: float
94
+ # d type: string
95
+ #
96
+ # Options:
97
+ #
98
+ # --help Get help on this command
@@ -0,0 +1,62 @@
1
+ #!/usr/bin/env ruby
2
+ $: << File.expand_path('lib')
3
+
4
+ require 'cl'
5
+
6
+ class Required < Cl::Cmd
7
+ register :required
8
+
9
+ arg :one, required: true
10
+ arg :two
11
+
12
+ def run
13
+ p cmd: registry_key, one: one, two: two
14
+ end
15
+ end
16
+
17
+ Cl.new($0).run(%w(required one two))
18
+
19
+ # Output:
20
+ #
21
+ # {:cmd=>:required, :one=>"one", :two=>"two"}
22
+
23
+ Cl.new($0).run(%w(required one))
24
+
25
+ # Output:
26
+ #
27
+ # {:cmd=>:required, :one=>"one", :two=>nil}
28
+
29
+ Cl.new($0).run(%w(required))
30
+
31
+ # Output:
32
+ #
33
+ # Missing arguments (given: 0, required: 1)
34
+ #
35
+ # Usage: bin/examples required one [two] [options]
36
+ #
37
+ # Arguments:
38
+ #
39
+ # one type: string, required
40
+ # two type: string
41
+ #
42
+ # Options:
43
+ #
44
+ # --help Get help on this command
45
+
46
+ Cl.new($0).run(%w(required one two three))
47
+
48
+ # Output:
49
+ #
50
+ # Too many arguments: one two three (given: 3, allowed: 2)
51
+ #
52
+ # Usage: bin/examples required one [two] [options]
53
+ #
54
+ # Arguments:
55
+ #
56
+ # one type: string, required
57
+ # two type: string
58
+ #
59
+ # Options:
60
+ #
61
+ # --help Get help on this command
62
+
@@ -0,0 +1,58 @@
1
+ #!/usr/bin/env ruby
2
+ $: << File.expand_path('lib')
3
+
4
+ require 'cl'
5
+
6
+ module Splat
7
+ class Left < Cl::Cmd
8
+ register :left
9
+
10
+ arg :one, type: :array, splat: true
11
+ args :two, :three
12
+
13
+ def run
14
+ p cmd: registry_key, one: one, two: two, three: three
15
+ end
16
+ end
17
+
18
+ class Middle < Cl::Cmd
19
+ register :middle
20
+
21
+ arg :one
22
+ arg :two, type: :array, splat: true
23
+ arg :three
24
+
25
+ def run
26
+ p cmd: registry_key, one: one, two: two, three: three
27
+ end
28
+ end
29
+
30
+ class Right < Cl::Cmd
31
+ register :right
32
+
33
+ args :one, :two
34
+ arg :three, type: :array, splat: true
35
+
36
+ def run
37
+ p cmd: registry_key, one: one, two: two, three: three
38
+ end
39
+ end
40
+ end
41
+
42
+ Cl.new('splat').run(%w(left foo bar baz buz))
43
+
44
+ # Output:
45
+ #
46
+ # {:cmd=>:left, :one=>["foo", "bar"], :two=>"baz", :three=>"buz"}
47
+
48
+ Cl.new('splat').run(%w(middle foo bar baz buz))
49
+
50
+ # Output:
51
+ #
52
+ # {:cmd=>:middle, :one=>"foo", :two=>["bar", "baz"], :three=>"buz"}
53
+
54
+ Cl.new('splat').run(%w(right foo bar baz buz))
55
+
56
+ # Output:
57
+ #
58
+ # {:cmd=>:right, :one=>"foo", :two=>"bar", :three=>["baz", "buz"]}
data/examples/gem ADDED
@@ -0,0 +1,97 @@
1
+ #!/usr/bin/env ruby
2
+ $: << File.expand_path('lib')
3
+
4
+ require 'cl'
5
+
6
+ module Gem
7
+ module Release
8
+ module Cmds
9
+ class Release < Cl::Cmd
10
+ register 'release'
11
+
12
+ arg :gemspec
13
+
14
+ opt '-h', '--host HOST', 'Push to a compatible host other than rubygems.org'
15
+ opt '-k', '--key KEY', 'Rubygems API key to use'
16
+ opt '-q', '--quiet', 'Silence output'
17
+
18
+ def run
19
+ p cmd: registry_key, args: args, opts: opts
20
+ end
21
+ end
22
+
23
+ class Bump < Cl::Cmd
24
+ register 'bump'
25
+
26
+ opt '-v', '--version VERSION', 'The version to bump to [1.1.1|major|minor|patch|pre|rc|release]'
27
+ opt '--[no-]commit', 'Bump the version, but do not commit'
28
+
29
+ def run
30
+ p cmd: registry_key, args: args, opts: opts
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
36
+
37
+ Cl.new('gem').run(%w(help))
38
+
39
+ # Output:
40
+ #
41
+ # Type "gem help COMMAND [SUBCOMMAND]" for more details:
42
+ #
43
+ # gem release [gemspec] [options]
44
+ # gem bump [options]
45
+
46
+
47
+ Cl.new('gem').run(%w(help release))
48
+ # or:
49
+ #
50
+ # Cl.new('gem').run(%w(release --help)))
51
+ # Cl.new('gem').run(%w(release -h)))
52
+ #
53
+ # Output:
54
+ #
55
+ # Usage: gem release [gemspec] [options]
56
+ #
57
+ # Arguments:
58
+ #
59
+ # gemspec type: string
60
+ #
61
+ # Options:
62
+ #
63
+ # -h --host HOST Push to a compatible host other than rubygems.org (type: string)
64
+ # -k --key KEY Rubygems API key to use (type: string)
65
+ # -q --[no-]quiet Silence output
66
+ # --help Get help on this command
67
+
68
+
69
+ Cl.new('gem').run(%w(help bump))
70
+ # or:
71
+ #
72
+ # Cl.new('gem').run(%w(bump --help)))
73
+ # Cl.new('gem').run(%w(bump -h)))
74
+ #
75
+ # Output:
76
+ #
77
+ # Usage: gem bump [options]
78
+ #
79
+ # Options:
80
+ #
81
+ # -v --version VERSION The version to bump to [1.1.1|major|minor|patch|pre|rc|release] (type: string)
82
+ # --[no-]commit Bump the version, but do not commit
83
+ # --help Get help on this command
84
+
85
+
86
+ Cl.new('gem').run(%w(bump -v 1.1.1))
87
+
88
+ # Output:
89
+ #
90
+ # {:cmd=>:bump, :args=>[], :opts=>{:version=>"1.1.1"}}
91
+
92
+
93
+ Cl.new('gem').run(%w(release foo.gemspec -h host -k key -q))
94
+
95
+ # Output:
96
+ #
97
+ # {:cmd=>:release, :args=>["foo.gemspec"], :opts=>{:host=>"host", :key=>"key", :quiet=>true}}
data/examples/heroku ADDED
@@ -0,0 +1,48 @@
1
+ #!/usr/bin/env ruby
2
+ $: << File.expand_path('lib')
3
+
4
+ require 'cl'
5
+
6
+ module Heroku
7
+ module Apps
8
+ class Create < Cl::Cmd
9
+ register 'apps:create'
10
+
11
+ arg :name, required: true
12
+
13
+ opt '-o', '--org ORG'
14
+
15
+ def run
16
+ p cmd: registry_key, args: args, opts: opts
17
+ end
18
+ end
19
+
20
+ class List < Cl::Cmd
21
+ register 'apps:info'
22
+
23
+ opt '-a', '--app APP'
24
+
25
+ def run
26
+ p cmd: registry_key, args: args, opts: opts
27
+ end
28
+ end
29
+ end
30
+ end
31
+
32
+ Cl.new('heroku').run(%w(apps:create name -o org))
33
+ # or:
34
+ #
35
+ # Cl.new('heroku').run(%w(apps create name -o org))
36
+
37
+ # Output:
38
+ #
39
+ # {:cmd=>:"apps:create", :args=>["name"], :opts=>{:org=>"org"}}
40
+
41
+ Cl.new('heroku').run(%w(apps:info -a app))
42
+ # or:
43
+ #
44
+ # Cl.new('heroku').run(%w(apps info -a app))
45
+
46
+ # Output:
47
+ #
48
+ # {:cmd=>:"apps:info", :args=>[], :opts=>{:app=>"app"}}
data/examples/rakeish ADDED
@@ -0,0 +1,50 @@
1
+ #!/usr/bin/env ruby
2
+ $: << File.expand_path('lib')
3
+
4
+ require 'cl'
5
+
6
+ module Rakeish
7
+ module Db
8
+ class Create < Cl::Cmd
9
+ register 'db:create'
10
+
11
+ arg :name
12
+
13
+ def run
14
+ p cmd: registry_key, args: args, opts: opts
15
+ end
16
+ end
17
+
18
+ class Drop < Cl::Cmd
19
+ register 'db:drop'
20
+
21
+ arg :name
22
+
23
+ opt '-f', '--force'
24
+
25
+ def run
26
+ p cmd: registry_key, args: args, opts: opts
27
+ end
28
+ end
29
+
30
+ class Migrate < Cl::Cmd
31
+ register 'db:migrate'
32
+
33
+ arg :name
34
+
35
+ opt '-v', '--version VERSION'
36
+
37
+ def run
38
+ p cmd: registry_key, args: args, opts: opts
39
+ end
40
+ end
41
+ end
42
+ end
43
+
44
+ Cl.new('rake', runner: :multi).run(%w(db:drop production -f db:create db:migrate production -v 1))
45
+
46
+ # Output:
47
+ #
48
+ # {:cmd=>:"db:drop", :args=>["production"], :opts=>{:force=>true}}
49
+ # {:cmd=>:"db:create", :args=>[], :opts=>{}}
50
+ # {:cmd=>:"db:migrate", :args=>["production"], :opts=>{:version=>"1"}}
@@ -0,0 +1,28 @@
1
+ #!/usr/bin/env ruby
2
+ $: << File.expand_path('lib')
3
+
4
+ require 'cl'
5
+
6
+ class Base < Cl::Cmd
7
+ abstract
8
+ end
9
+
10
+ class Add < Base
11
+ register :add
12
+
13
+ def run
14
+ puts 'Success'
15
+ end
16
+ end
17
+
18
+ Cl.new('owners').run(%w(add))
19
+
20
+ # Output:
21
+ #
22
+ # Success
23
+
24
+ Cl.new('owners').run(%w(base))
25
+
26
+ # Output:
27
+ #
28
+ # Unknown command: base