travis-cl 1.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +134 -0
- data/Gemfile +11 -0
- data/Gemfile.lock +59 -0
- data/MIT_LICENSE.md +21 -0
- data/README.md +1283 -0
- data/cl.gemspec +30 -0
- data/examples/README.md +22 -0
- data/examples/_src/args/cast.erb.rb +100 -0
- data/examples/_src/args/opts.erb.rb +100 -0
- data/examples/_src/args/required.erb.rb +63 -0
- data/examples/_src/args/splat.erb.rb +55 -0
- data/examples/_src/gem.erb.rb +99 -0
- data/examples/_src/heroku.erb.rb +47 -0
- data/examples/_src/rakeish.erb.rb +54 -0
- data/examples/_src/readme/abstract.erb.rb +27 -0
- data/examples/_src/readme/alias.erb.rb +22 -0
- data/examples/_src/readme/arg.erb.rb +21 -0
- data/examples/_src/readme/arg_array.erb.rb +21 -0
- data/examples/_src/readme/arg_type.erb.rb +23 -0
- data/examples/_src/readme/args_splat.erb.rb +55 -0
- data/examples/_src/readme/array.erb.rb +21 -0
- data/examples/_src/readme/basic.erb.rb +72 -0
- data/examples/_src/readme/default.erb.rb +21 -0
- data/examples/_src/readme/deprecated.erb.rb +21 -0
- data/examples/_src/readme/deprecated_alias.erb.rb +21 -0
- data/examples/_src/readme/description.erb.rb +60 -0
- data/examples/_src/readme/downcase.erb.rb +21 -0
- data/examples/_src/readme/enum.erb.rb +35 -0
- data/examples/_src/readme/example.erb.rb +25 -0
- data/examples/_src/readme/format.erb.rb +35 -0
- data/examples/_src/readme/internal.erb.rb +28 -0
- data/examples/_src/readme/negate.erb.rb +37 -0
- data/examples/_src/readme/note.erb.rb +25 -0
- data/examples/_src/readme/opts.erb.rb +33 -0
- data/examples/_src/readme/opts_block.erb.rb +30 -0
- data/examples/_src/readme/range.erb.rb +35 -0
- data/examples/_src/readme/registry.erb.rb +18 -0
- data/examples/_src/readme/required.erb.rb +35 -0
- data/examples/_src/readme/requireds.erb.rb +46 -0
- data/examples/_src/readme/requires.erb.rb +35 -0
- data/examples/_src/readme/runner.erb.rb +29 -0
- data/examples/_src/readme/runner_custom.erb.rb +25 -0
- data/examples/_src/readme/secret.erb.rb +22 -0
- data/examples/_src/readme/see.erb.rb +25 -0
- data/examples/_src/readme/type.erb.rb +21 -0
- data/examples/args/cast +98 -0
- data/examples/args/opts +98 -0
- data/examples/args/required +62 -0
- data/examples/args/splat +58 -0
- data/examples/gem +97 -0
- data/examples/heroku +48 -0
- data/examples/rakeish +50 -0
- data/examples/readme/abstract +28 -0
- data/examples/readme/alias +21 -0
- data/examples/readme/arg +20 -0
- data/examples/readme/arg_array +20 -0
- data/examples/readme/arg_type +22 -0
- data/examples/readme/args_splat +58 -0
- data/examples/readme/array +20 -0
- data/examples/readme/basic +67 -0
- data/examples/readme/default +20 -0
- data/examples/readme/deprecated +20 -0
- data/examples/readme/deprecated_alias +20 -0
- data/examples/readme/description +56 -0
- data/examples/readme/downcase +20 -0
- data/examples/readme/enum +33 -0
- data/examples/readme/example +21 -0
- data/examples/readme/format +33 -0
- data/examples/readme/internal +24 -0
- data/examples/readme/negate +44 -0
- data/examples/readme/note +21 -0
- data/examples/readme/opts +31 -0
- data/examples/readme/opts_block +29 -0
- data/examples/readme/range +33 -0
- data/examples/readme/registry +15 -0
- data/examples/readme/required +33 -0
- data/examples/readme/requireds +46 -0
- data/examples/readme/requires +33 -0
- data/examples/readme/runner +30 -0
- data/examples/readme/runner_custom +22 -0
- data/examples/readme/secret +21 -0
- data/examples/readme/see +21 -0
- data/examples/readme/type +20 -0
- data/lib/cl/arg.rb +79 -0
- data/lib/cl/args.rb +92 -0
- data/lib/cl/cast.rb +55 -0
- data/lib/cl/cmd.rb +74 -0
- data/lib/cl/config/env.rb +52 -0
- data/lib/cl/config/files.rb +34 -0
- data/lib/cl/config.rb +30 -0
- data/lib/cl/ctx.rb +36 -0
- data/lib/cl/dsl.rb +182 -0
- data/lib/cl/errors.rb +119 -0
- data/lib/cl/help/cmd.rb +118 -0
- data/lib/cl/help/cmds.rb +26 -0
- data/lib/cl/help/format.rb +69 -0
- data/lib/cl/help/table.rb +58 -0
- data/lib/cl/help/usage.rb +26 -0
- data/lib/cl/help.rb +37 -0
- data/lib/cl/helper/suggest.rb +10 -0
- data/lib/cl/helper.rb +47 -0
- data/lib/cl/opt.rb +276 -0
- data/lib/cl/opts/validate.rb +117 -0
- data/lib/cl/opts.rb +114 -0
- data/lib/cl/parser/format.rb +63 -0
- data/lib/cl/parser.rb +70 -0
- data/lib/cl/runner/default.rb +86 -0
- data/lib/cl/runner/multi.rb +34 -0
- data/lib/cl/runner.rb +10 -0
- data/lib/cl/ui.rb +146 -0
- data/lib/cl/version.rb +3 -0
- data/lib/cl.rb +62 -0
- metadata +177 -0
data/cl.gemspec
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
$:.unshift File.expand_path('../lib', __FILE__)
|
4
|
+
require 'cl/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = 'travis-cl'
|
8
|
+
s.version = Cl::VERSION
|
9
|
+
s.authors = ['Sven Fuchs']
|
10
|
+
s.homepage = 'https://github.com/svenfuchs/cl'
|
11
|
+
s.licenses = ['MIT']
|
12
|
+
s.summary = 'Object-oriented OptionParser based CLI support'
|
13
|
+
s.description = <<-str.strip.gsub(/^ +/, '')
|
14
|
+
OptionParser based CLI support for rapid CLI development in an object-oriented
|
15
|
+
context.
|
16
|
+
|
17
|
+
This library wraps Ruby's OptionParser for parsing your options under the hood,
|
18
|
+
so you get all the goodness that the Ruby standard library provides.
|
19
|
+
|
20
|
+
On top of that it adds a rich and powerful DSL for defining, validating, and
|
21
|
+
normalizing options, as well as automatic and gorgeous help output (modeled
|
22
|
+
after `gem --help`).
|
23
|
+
str
|
24
|
+
|
25
|
+
s.files = Dir.glob('{examples/**/*,lib/**/*,[A-Z]*}')
|
26
|
+
s.platform = Gem::Platform::RUBY
|
27
|
+
s.require_path = 'lib'
|
28
|
+
|
29
|
+
s.add_dependency 'regstry', '~> 1.0'
|
30
|
+
end
|
data/examples/README.md
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# Cl Examples
|
2
|
+
|
3
|
+
This directory contains examples for using `cl`.
|
4
|
+
|
5
|
+
Examples are executable, so you can try them out and experiment with them. E.g.:
|
6
|
+
|
7
|
+
```
|
8
|
+
git clone https://github.com/svenfuchs/cl.git /tmp/cl
|
9
|
+
cd /tmp/cl
|
10
|
+
examples/gem
|
11
|
+
```
|
12
|
+
|
13
|
+
Examples are generated and verified by running:
|
14
|
+
|
15
|
+
```
|
16
|
+
bundle exec bin/examples
|
17
|
+
```
|
18
|
+
|
19
|
+
This command runs on [on Travis CI](https://github.com/svenfuchs/cl/blob/master/.travis.yml#L14)
|
20
|
+
in order to guarantee that all examples are up to date,
|
21
|
+
but also can be run in order to add or update examples.
|
22
|
+
|
@@ -0,0 +1,100 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
$: << File.expand_path('lib')
|
3
|
+
|
4
|
+
<%= run sq(<<-'rb')
|
5
|
+
require 'cl'
|
6
|
+
|
7
|
+
module Cast
|
8
|
+
class Bool < Cl::Cmd
|
9
|
+
register :bool
|
10
|
+
|
11
|
+
arg :bool, type: :bool
|
12
|
+
|
13
|
+
def run
|
14
|
+
p cmd: registry_key, bool: bool
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
class Types < Cl::Cmd
|
19
|
+
register :types
|
20
|
+
|
21
|
+
arg :a, type: :bool
|
22
|
+
arg :b, type: :int
|
23
|
+
arg :c, type: :float
|
24
|
+
arg :d
|
25
|
+
|
26
|
+
def run
|
27
|
+
p cmd: registry_key, a: a, b: b, c: c, d: d
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
rb
|
32
|
+
-%>
|
33
|
+
|
34
|
+
<%= run 'Cl.new($0).run(%w(bool on))' %>
|
35
|
+
|
36
|
+
<%= out '{:cmd=>:bool, :bool=>true}' %>
|
37
|
+
|
38
|
+
<%= run 'Cl.new($0).run(%w(types true 1 1.2 foo))' %>
|
39
|
+
|
40
|
+
<%= out '{:cmd=>:types, :a=>true, :b=>1, :c=>1.2, :d=>"foo"}' %>
|
41
|
+
|
42
|
+
<%= run 'Cl.new($0).run(%w(types true 1 1.2 foo bar))' %>
|
43
|
+
|
44
|
+
<%= out sq(<<-'str')
|
45
|
+
Too many arguments: true 1 1.2 foo bar (given: 5, allowed: 4)
|
46
|
+
|
47
|
+
Usage: bin/examples types [a:bool] [b:int] [c:float] [d] [options]
|
48
|
+
|
49
|
+
Arguments:
|
50
|
+
|
51
|
+
a type: bool
|
52
|
+
b type: int
|
53
|
+
c type: float
|
54
|
+
d type: string
|
55
|
+
|
56
|
+
Options:
|
57
|
+
|
58
|
+
--help Get help on this command
|
59
|
+
str
|
60
|
+
%>
|
61
|
+
|
62
|
+
<%= run 'Cl.new($0).run(%w(types true one 1.2))' %>
|
63
|
+
|
64
|
+
<%= out sq(<<-'str')
|
65
|
+
Wrong argument type (given: "one", expected: int)
|
66
|
+
|
67
|
+
Usage: bin/examples types [a:bool] [b:int] [c:float] [d] [options]
|
68
|
+
|
69
|
+
Arguments:
|
70
|
+
|
71
|
+
a type: bool
|
72
|
+
b type: int
|
73
|
+
c type: float
|
74
|
+
d type: string
|
75
|
+
|
76
|
+
Options:
|
77
|
+
|
78
|
+
--help Get help on this command
|
79
|
+
str
|
80
|
+
%>
|
81
|
+
|
82
|
+
<%= run 'Cl.new($0).run(%w(types true 1 one))' %>
|
83
|
+
|
84
|
+
<%= out sq(<<-'str')
|
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
|
99
|
+
str
|
100
|
+
%>
|
@@ -0,0 +1,100 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
$: << File.expand_path('lib')
|
3
|
+
|
4
|
+
<%= run sq(<<-'rb')
|
5
|
+
require 'cl'
|
6
|
+
|
7
|
+
module Opts
|
8
|
+
class Bool < Cl::Cmd
|
9
|
+
register :bool
|
10
|
+
|
11
|
+
arg :bool, type: :bool
|
12
|
+
|
13
|
+
def run
|
14
|
+
p cmd: registry_key, bool: bool
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
class Types < Cl::Cmd
|
19
|
+
register :types
|
20
|
+
|
21
|
+
arg :a, type: :bool
|
22
|
+
arg :b, type: :int
|
23
|
+
arg :c, type: :float
|
24
|
+
arg :d
|
25
|
+
|
26
|
+
def run
|
27
|
+
p cmd: registry_key, a: a, b: b, c: c, d: d
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
rb
|
32
|
+
-%>
|
33
|
+
|
34
|
+
<%= run 'Cl.new($0).run(%w(bool on))' %>
|
35
|
+
|
36
|
+
<%= out '{:cmd=>:bool, :bool=>true}' %>
|
37
|
+
|
38
|
+
<%= run 'Cl.new($0).run(%w(types true 1 1.2 foo))' %>
|
39
|
+
|
40
|
+
<%= out '{:cmd=>:types, :a=>true, :b=>1, :c=>1.2, :d=>"foo"}' %>
|
41
|
+
|
42
|
+
<%= run 'Cl.new($0).run(%w(types true 1 1.2 foo bar))' %>
|
43
|
+
|
44
|
+
<%= out sq(<<-'str')
|
45
|
+
Too many arguments: true 1 1.2 foo bar (given: 5, allowed: 4)
|
46
|
+
|
47
|
+
Usage: bin/examples types [a:bool] [b:int] [c:float] [d] [options]
|
48
|
+
|
49
|
+
Arguments:
|
50
|
+
|
51
|
+
a type: bool
|
52
|
+
b type: int
|
53
|
+
c type: float
|
54
|
+
d type: string
|
55
|
+
|
56
|
+
Options:
|
57
|
+
|
58
|
+
--help Get help on this command
|
59
|
+
str
|
60
|
+
%>
|
61
|
+
|
62
|
+
<%= run 'Cl.new($0).run(%w(types true one 1.2))' %>
|
63
|
+
|
64
|
+
<%= out sq(<<-'str')
|
65
|
+
Wrong argument type (given: "one", expected: int)
|
66
|
+
|
67
|
+
Usage: bin/examples types [a:bool] [b:int] [c:float] [d] [options]
|
68
|
+
|
69
|
+
Arguments:
|
70
|
+
|
71
|
+
a type: bool
|
72
|
+
b type: int
|
73
|
+
c type: float
|
74
|
+
d type: string
|
75
|
+
|
76
|
+
Options:
|
77
|
+
|
78
|
+
--help Get help on this command
|
79
|
+
str
|
80
|
+
%>
|
81
|
+
|
82
|
+
<%= run 'Cl.new($0).run(%w(types true 1 one))' %>
|
83
|
+
|
84
|
+
<%= out sq(<<-'str')
|
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
|
99
|
+
str
|
100
|
+
%>
|
@@ -0,0 +1,63 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
$: << File.expand_path('lib')
|
3
|
+
|
4
|
+
<%= run sq(<<-'rb')
|
5
|
+
require 'cl'
|
6
|
+
|
7
|
+
class Required < Cl::Cmd
|
8
|
+
register :required
|
9
|
+
|
10
|
+
arg :one, required: true
|
11
|
+
arg :two
|
12
|
+
|
13
|
+
def run
|
14
|
+
p cmd: registry_key, one: one, two: two
|
15
|
+
end
|
16
|
+
end
|
17
|
+
rb
|
18
|
+
-%>
|
19
|
+
|
20
|
+
<%= run 'Cl.new($0).run(%w(required one two))' %>
|
21
|
+
|
22
|
+
<%= out '{:cmd=>:required, :one=>"one", :two=>"two"}' %>
|
23
|
+
|
24
|
+
<%= run 'Cl.new($0).run(%w(required one))' %>
|
25
|
+
|
26
|
+
<%= out '{:cmd=>:required, :one=>"one", :two=>nil}' %>
|
27
|
+
|
28
|
+
<%= run 'Cl.new($0).run(%w(required))' %>
|
29
|
+
|
30
|
+
<%= out sq(<<-'str')
|
31
|
+
Missing arguments (given: 0, required: 1)
|
32
|
+
|
33
|
+
Usage: bin/examples required one [two] [options]
|
34
|
+
|
35
|
+
Arguments:
|
36
|
+
|
37
|
+
one type: string, required
|
38
|
+
two type: string
|
39
|
+
|
40
|
+
Options:
|
41
|
+
|
42
|
+
--help Get help on this command
|
43
|
+
str
|
44
|
+
%>
|
45
|
+
|
46
|
+
<%= run 'Cl.new($0).run(%w(required one two three))' %>
|
47
|
+
|
48
|
+
<%= out sq(<<-'str')
|
49
|
+
Too many arguments: one two three (given: 3, allowed: 2)
|
50
|
+
|
51
|
+
Usage: bin/examples required one [two] [options]
|
52
|
+
|
53
|
+
Arguments:
|
54
|
+
|
55
|
+
one type: string, required
|
56
|
+
two type: string
|
57
|
+
|
58
|
+
Options:
|
59
|
+
|
60
|
+
--help Get help on this command
|
61
|
+
str
|
62
|
+
%>
|
63
|
+
|
@@ -0,0 +1,55 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
$: << File.expand_path('lib')
|
3
|
+
|
4
|
+
<%= run sq(<<-'rb')
|
5
|
+
require 'cl'
|
6
|
+
|
7
|
+
module Splat
|
8
|
+
class Left < Cl::Cmd
|
9
|
+
register :left
|
10
|
+
|
11
|
+
arg :one, type: :array, splat: true
|
12
|
+
args :two, :three
|
13
|
+
|
14
|
+
def run
|
15
|
+
p cmd: registry_key, one: one, two: two, three: three
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
class Middle < Cl::Cmd
|
20
|
+
register :middle
|
21
|
+
|
22
|
+
arg :one
|
23
|
+
arg :two, type: :array, splat: true
|
24
|
+
arg :three
|
25
|
+
|
26
|
+
def run
|
27
|
+
p cmd: registry_key, one: one, two: two, three: three
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
class Right < Cl::Cmd
|
32
|
+
register :right
|
33
|
+
|
34
|
+
args :one, :two
|
35
|
+
arg :three, type: :array, splat: true
|
36
|
+
|
37
|
+
def run
|
38
|
+
p cmd: registry_key, one: one, two: two, three: three
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
rb
|
43
|
+
-%>
|
44
|
+
|
45
|
+
<%= run "Cl.new('splat').run(%w(left foo bar baz buz))" %>
|
46
|
+
|
47
|
+
<%= out '{:cmd=>:left, :one=>["foo", "bar"], :two=>"baz", :three=>"buz"}' %>
|
48
|
+
|
49
|
+
<%= run "Cl.new('splat').run(%w(middle foo bar baz buz))" %>
|
50
|
+
|
51
|
+
<%= out '{:cmd=>:middle, :one=>"foo", :two=>["bar", "baz"], :three=>"buz"}' %>
|
52
|
+
|
53
|
+
<%= run "Cl.new('splat').run(%w(right foo bar baz buz))" %>
|
54
|
+
|
55
|
+
<%= out '{:cmd=>:right, :one=>"foo", :two=>"bar", :three=>["baz", "buz"]}' %>
|
@@ -0,0 +1,99 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
$: << File.expand_path('lib')
|
3
|
+
|
4
|
+
<%= run sq(<<-'rb')
|
5
|
+
require 'cl'
|
6
|
+
|
7
|
+
module Gem
|
8
|
+
module Release
|
9
|
+
module Cmds
|
10
|
+
class Release < Cl::Cmd
|
11
|
+
register 'release'
|
12
|
+
|
13
|
+
arg :gemspec
|
14
|
+
|
15
|
+
opt '-h', '--host HOST', 'Push to a compatible host other than rubygems.org'
|
16
|
+
opt '-k', '--key KEY', 'Rubygems API key to use'
|
17
|
+
opt '-q', '--quiet', 'Silence output'
|
18
|
+
|
19
|
+
def run
|
20
|
+
p cmd: registry_key, args: args, opts: opts
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
class Bump < Cl::Cmd
|
25
|
+
register 'bump'
|
26
|
+
|
27
|
+
opt '-v', '--version VERSION', 'The version to bump to [1.1.1|major|minor|patch|pre|rc|release]'
|
28
|
+
opt '--[no-]commit', 'Bump the version, but do not commit'
|
29
|
+
|
30
|
+
def run
|
31
|
+
p cmd: registry_key, args: args, opts: opts
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
rb
|
38
|
+
-%>
|
39
|
+
|
40
|
+
<%= run "Cl.new('gem').run(%w(help))" %>
|
41
|
+
|
42
|
+
<%= out sq(<<-'str')
|
43
|
+
Type "gem help COMMAND [SUBCOMMAND]" for more details:
|
44
|
+
|
45
|
+
gem release [gemspec] [options]
|
46
|
+
gem bump [options]
|
47
|
+
str
|
48
|
+
%>
|
49
|
+
|
50
|
+
|
51
|
+
<%= run "Cl.new('gem').run(%w(help release))" %>
|
52
|
+
# or:
|
53
|
+
#
|
54
|
+
# Cl.new('gem').run(%w(release --help)))
|
55
|
+
# Cl.new('gem').run(%w(release -h)))
|
56
|
+
#
|
57
|
+
<%= out sq(<<-'str')
|
58
|
+
Usage: gem release [gemspec] [options]
|
59
|
+
|
60
|
+
Arguments:
|
61
|
+
|
62
|
+
gemspec type: string
|
63
|
+
|
64
|
+
Options:
|
65
|
+
|
66
|
+
-h --host HOST Push to a compatible host other than rubygems.org (type: string)
|
67
|
+
-k --key KEY Rubygems API key to use (type: string)
|
68
|
+
-q --[no-]quiet Silence output
|
69
|
+
--help Get help on this command
|
70
|
+
str
|
71
|
+
%>
|
72
|
+
|
73
|
+
|
74
|
+
<%= run "Cl.new('gem').run(%w(help bump))" %>
|
75
|
+
# or:
|
76
|
+
#
|
77
|
+
# Cl.new('gem').run(%w(bump --help)))
|
78
|
+
# Cl.new('gem').run(%w(bump -h)))
|
79
|
+
#
|
80
|
+
<%= out sq(<<-'str')
|
81
|
+
Usage: gem bump [options]
|
82
|
+
|
83
|
+
Options:
|
84
|
+
|
85
|
+
-v --version VERSION The version to bump to [1.1.1|major|minor|patch|pre|rc|release] (type: string)
|
86
|
+
--[no-]commit Bump the version, but do not commit
|
87
|
+
--help Get help on this command
|
88
|
+
str
|
89
|
+
%>
|
90
|
+
|
91
|
+
|
92
|
+
<%= run "Cl.new('gem').run(%w(bump -v 1.1.1))" %>
|
93
|
+
|
94
|
+
<%= out '{:cmd=>:bump, :args=>[], :opts=>{:version=>"1.1.1"}}' %>
|
95
|
+
|
96
|
+
|
97
|
+
<%= run "Cl.new('gem').run(%w(release foo.gemspec -h host -k key -q))" %>
|
98
|
+
|
99
|
+
<%= out '{:cmd=>:release, :args=>["foo.gemspec"], :opts=>{:host=>"host", :key=>"key", :quiet=>true}}' %>
|
@@ -0,0 +1,47 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
$: << File.expand_path('lib')
|
3
|
+
|
4
|
+
<%= run sq(<<-'rb')
|
5
|
+
require 'cl'
|
6
|
+
|
7
|
+
module Heroku
|
8
|
+
module Apps
|
9
|
+
class Create < Cl::Cmd
|
10
|
+
register 'apps:create'
|
11
|
+
|
12
|
+
arg :name, required: true
|
13
|
+
|
14
|
+
opt '-o', '--org ORG'
|
15
|
+
|
16
|
+
def run
|
17
|
+
p cmd: registry_key, args: args, opts: opts
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
class List < Cl::Cmd
|
22
|
+
register 'apps:info'
|
23
|
+
|
24
|
+
opt '-a', '--app APP'
|
25
|
+
|
26
|
+
def run
|
27
|
+
p cmd: registry_key, args: args, opts: opts
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
rb
|
33
|
+
-%>
|
34
|
+
|
35
|
+
<%= run "Cl.new('heroku').run(%w(apps:create name -o org))" %>
|
36
|
+
# or:
|
37
|
+
#
|
38
|
+
# Cl.new('heroku').run(%w(apps create name -o org))
|
39
|
+
|
40
|
+
<%= out '{:cmd=>:"apps:create", :args=>["name"], :opts=>{:org=>"org"}}' %>
|
41
|
+
|
42
|
+
<%= run "Cl.new('heroku').run(%w(apps:info -a app))" %>
|
43
|
+
# or:
|
44
|
+
#
|
45
|
+
# Cl.new('heroku').run(%w(apps info -a app))
|
46
|
+
|
47
|
+
<%= out '{:cmd=>:"apps:info", :args=>[], :opts=>{:app=>"app"}}' %>
|
@@ -0,0 +1,54 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
$: << File.expand_path('lib')
|
3
|
+
|
4
|
+
<%= run sq(<<-'rb')
|
5
|
+
require 'cl'
|
6
|
+
|
7
|
+
module Rakeish
|
8
|
+
module Db
|
9
|
+
class Create < Cl::Cmd
|
10
|
+
register 'db:create'
|
11
|
+
|
12
|
+
arg :name
|
13
|
+
|
14
|
+
def run
|
15
|
+
p cmd: registry_key, args: args, opts: opts
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
class Drop < Cl::Cmd
|
20
|
+
register 'db:drop'
|
21
|
+
|
22
|
+
arg :name
|
23
|
+
|
24
|
+
opt '-f', '--force'
|
25
|
+
|
26
|
+
def run
|
27
|
+
p cmd: registry_key, args: args, opts: opts
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
class Migrate < Cl::Cmd
|
32
|
+
register 'db:migrate'
|
33
|
+
|
34
|
+
arg :name
|
35
|
+
|
36
|
+
opt '-v', '--version VERSION'
|
37
|
+
|
38
|
+
def run
|
39
|
+
p cmd: registry_key, args: args, opts: opts
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
rb
|
45
|
+
-%>
|
46
|
+
|
47
|
+
<%= run "Cl.new('rake', runner: :multi).run(%w(db:drop production -f db:create db:migrate production -v 1))" %>
|
48
|
+
|
49
|
+
<%= out sq(<<-'str')
|
50
|
+
{:cmd=>:"db:drop", :args=>["production"], :opts=>{:force=>true}}
|
51
|
+
{:cmd=>:"db:create", :args=>[], :opts=>{}}
|
52
|
+
{:cmd=>:"db:migrate", :args=>["production"], :opts=>{:version=>"1"}}
|
53
|
+
str
|
54
|
+
%>
|
@@ -0,0 +1,27 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
$: << File.expand_path('lib')
|
3
|
+
|
4
|
+
require 'cl'
|
5
|
+
|
6
|
+
<%= run sq(<<-'rb')
|
7
|
+
class Base < Cl::Cmd
|
8
|
+
abstract
|
9
|
+
end
|
10
|
+
|
11
|
+
class Add < Base
|
12
|
+
register :add
|
13
|
+
|
14
|
+
def run
|
15
|
+
puts 'Success'
|
16
|
+
end
|
17
|
+
end
|
18
|
+
rb
|
19
|
+
-%>
|
20
|
+
|
21
|
+
<%= run "Cl.new('owners').run(%w(add))" %>
|
22
|
+
|
23
|
+
<%= out 'Success' %>
|
24
|
+
|
25
|
+
<%= run "Cl.new('owners').run(%w(base))" %>
|
26
|
+
|
27
|
+
<%= out 'Unknown command: base' %>
|
@@ -0,0 +1,22 @@
|
|
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', alias: :group
|
11
|
+
|
12
|
+
def run
|
13
|
+
# p opts: opts, to: to, to?: to?, group: group, group?: group?
|
14
|
+
p opts: opts, to: to, to?: to?
|
15
|
+
end
|
16
|
+
end
|
17
|
+
rb
|
18
|
+
-%>
|
19
|
+
|
20
|
+
<%= run "Cl.new('owners').run(%w(add --group one))" %>
|
21
|
+
|
22
|
+
<%= out '{:opts=>{:to=>"one", :group=>"one"}, :to=>"one", :to?=>true}' %>
|
@@ -0,0 +1,21 @@
|
|
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
|
+
arg :owner
|
11
|
+
|
12
|
+
def run
|
13
|
+
p owner: owner
|
14
|
+
end
|
15
|
+
end
|
16
|
+
rb
|
17
|
+
-%>
|
18
|
+
|
19
|
+
<%= run "Cl.new('owners').run(%w(add one))" %>
|
20
|
+
|
21
|
+
<%= out '{:owner=>"one"}' %>
|
@@ -0,0 +1,21 @@
|
|
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
|
+
arg :owners, type: :array, sep: ','
|
11
|
+
|
12
|
+
def run
|
13
|
+
p owners: owners
|
14
|
+
end
|
15
|
+
end
|
16
|
+
rb
|
17
|
+
-%>
|
18
|
+
|
19
|
+
<%= run "Cl.new('owners').run(%w(add one,two))" %>
|
20
|
+
|
21
|
+
<%= out '{:owners=>["one", "two"]}' %>
|
@@ -0,0 +1,23 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
$: << File.expand_path('lib')
|
3
|
+
|
4
|
+
<%= run sq(<<-'rb')
|
5
|
+
require 'cl'
|
6
|
+
|
7
|
+
class Cmd < Cl::Cmd
|
8
|
+
register :cmd
|
9
|
+
|
10
|
+
arg :one, type: :integer
|
11
|
+
arg :two, type: :float
|
12
|
+
arg :three, type: :boolean
|
13
|
+
|
14
|
+
def run
|
15
|
+
p [one.class, two.class, three.class]
|
16
|
+
end
|
17
|
+
end
|
18
|
+
rb
|
19
|
+
-%>
|
20
|
+
|
21
|
+
<%= run "Cl.new('owners').run(%w(cmd 1 2.1 yes))" %>
|
22
|
+
|
23
|
+
<%= out "[#{RUBY_VERSION < '2.4' ? 'Fixnum' : 'Integer'}, Float, TrueClass]" %>
|