run_tasks 3.1.3 → 3.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHEATSHEET.md +212 -0
- data/src/bootstrap.rb +6 -0
- data/src/run/helper/are_you_sure_helper.rb +1 -1
- data/src/run/helper/exists_helper.rb +19 -0
- metadata +3 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d9a68d0e13118096e666e14fe7d9017555028b5fb3aa03501b2f818fa459528c
|
|
4
|
+
data.tar.gz: 548eb3281cadebf9282dcecbe7336916b2026751cfa1fee1294e3cd709160b43
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 40c8dcc4c1a5521202b367e56da1afa60e5da97acddfdd516a5ebce791471b8092161d7e44c9550be80bc80326671d4466f33e080f134735479fa08c67d83204
|
|
7
|
+
data.tar.gz: a88efe99f700e0bf1bf70e79c12a494afa411f1a3429ce7aaf330ba2f8dadc78e98c12ad1df82d08551ef668b8a51ec1b5ee180c499d9b881166dd8cc2fc9828
|
data/CHEATSHEET.md
ADDED
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
# Run cheatsheet
|
|
2
|
+
|
|
3
|
+
## Defining a task
|
|
4
|
+
|
|
5
|
+
```rb
|
|
6
|
+
task :eslint do
|
|
7
|
+
end
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
## Defining a task with aliases
|
|
11
|
+
|
|
12
|
+
```rb
|
|
13
|
+
task [:console, :c] do
|
|
14
|
+
end
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Defining a task with parameters
|
|
18
|
+
|
|
19
|
+
```rb
|
|
20
|
+
task :hello do |name, age|
|
|
21
|
+
puts "Hello #{name}, you are #{age}."
|
|
22
|
+
end
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Running commands
|
|
26
|
+
|
|
27
|
+
```rb
|
|
28
|
+
task :clear_all do
|
|
29
|
+
run "rm -rf /*"
|
|
30
|
+
end
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Running subtasks
|
|
34
|
+
|
|
35
|
+
```rb
|
|
36
|
+
task :linting do
|
|
37
|
+
run :eslint
|
|
38
|
+
run :rubocop
|
|
39
|
+
end
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Running a task/command in quiet mode
|
|
43
|
+
|
|
44
|
+
```rb
|
|
45
|
+
task :clear_cache do
|
|
46
|
+
run "rm -rf cache/*", quiet: true
|
|
47
|
+
end
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Using named booleans
|
|
51
|
+
|
|
52
|
+
```sh
|
|
53
|
+
run server +tunnel
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
```rb
|
|
57
|
+
task :server do |tunnel: false|
|
|
58
|
+
run "http_server #{tunnel ? "--tunnel" : ""}"
|
|
59
|
+
end
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Helpers
|
|
63
|
+
|
|
64
|
+
### are_you_sure
|
|
65
|
+
|
|
66
|
+
```rb
|
|
67
|
+
task :dangerous_task do
|
|
68
|
+
are_you_sure "This task will delete your hard drive. Are you sure about that?"
|
|
69
|
+
# Some dangerous actions.
|
|
70
|
+
end
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### bind
|
|
74
|
+
|
|
75
|
+
```rb
|
|
76
|
+
task :dev do
|
|
77
|
+
bind :rails, :vite
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
task :rails do
|
|
81
|
+
run "bundle exec unicorn -c config/unicorn.rb -p 3000"
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
task :vite do
|
|
85
|
+
run "bin/vite dev"
|
|
86
|
+
end
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### catch_interruption
|
|
90
|
+
|
|
91
|
+
```rb
|
|
92
|
+
task :server do
|
|
93
|
+
catch_interruption("docker run -d -p 8080:80 web_server") do
|
|
94
|
+
run :clear_cache
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### exists
|
|
100
|
+
|
|
101
|
+
```rb
|
|
102
|
+
task :man do
|
|
103
|
+
command = exists("bat") ? "bat" : "cat"
|
|
104
|
+
run "#{command} #{__dir__}/README.md"
|
|
105
|
+
end
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### expand
|
|
109
|
+
|
|
110
|
+
```rb
|
|
111
|
+
task :scan do |glob|
|
|
112
|
+
expand(glob).each do |file_path|
|
|
113
|
+
puts file_path
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### menu
|
|
119
|
+
|
|
120
|
+
```rb
|
|
121
|
+
task :deploy_aws do
|
|
122
|
+
region = menu "Location?", ["us‑east‑2", "us-west-1", "eu-west-1"]
|
|
123
|
+
end
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
```rb
|
|
127
|
+
task :deploy_aws do
|
|
128
|
+
region = menu "Location?", {
|
|
129
|
+
"US East (Ohio)" => "us‑east‑2",
|
|
130
|
+
"US West (N. California)" => "us-west-1",
|
|
131
|
+
"Europe (Ireland)" => "eu-west-1",
|
|
132
|
+
}
|
|
133
|
+
end
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### pause
|
|
137
|
+
|
|
138
|
+
```rb
|
|
139
|
+
task :deploy do
|
|
140
|
+
puts "Press enter to continue.".yellow
|
|
141
|
+
pause
|
|
142
|
+
run :deploy_production
|
|
143
|
+
end
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### question
|
|
147
|
+
|
|
148
|
+
```rb
|
|
149
|
+
task :survey do
|
|
150
|
+
comment = question "Did your meal was good?"
|
|
151
|
+
end
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
```rb
|
|
155
|
+
task :age do
|
|
156
|
+
age = question "What is your age?", /^\d+$/
|
|
157
|
+
end
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### wait_for_interruption
|
|
161
|
+
|
|
162
|
+
```rb
|
|
163
|
+
task :server do
|
|
164
|
+
Thread.new do
|
|
165
|
+
run :rails
|
|
166
|
+
end
|
|
167
|
+
Thread.new do
|
|
168
|
+
run :vite
|
|
169
|
+
end
|
|
170
|
+
wait_for_interruption do
|
|
171
|
+
run :kill_rails
|
|
172
|
+
run :kill_vite
|
|
173
|
+
end
|
|
174
|
+
end
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
## Colorization
|
|
178
|
+
|
|
179
|
+
```rb
|
|
180
|
+
puts "hello".bold
|
|
181
|
+
puts "hello".dim
|
|
182
|
+
puts "hello".italic
|
|
183
|
+
puts "hello".underline
|
|
184
|
+
puts "hello".inverse
|
|
185
|
+
puts "hello".strikethrough
|
|
186
|
+
puts "hello".black
|
|
187
|
+
puts "hello".red
|
|
188
|
+
puts "hello".green
|
|
189
|
+
puts "hello".yellow
|
|
190
|
+
puts "hello".blue
|
|
191
|
+
puts "hello".magenta
|
|
192
|
+
puts "hello".cyan
|
|
193
|
+
puts "hello".white
|
|
194
|
+
puts "hello".bright_black
|
|
195
|
+
puts "hello".bright_red
|
|
196
|
+
puts "hello".bright_green
|
|
197
|
+
puts "hello".bright_yellow
|
|
198
|
+
puts "hello".bright_blue
|
|
199
|
+
puts "hello".bright_magenta
|
|
200
|
+
puts "hello".bright_cyan
|
|
201
|
+
puts "hello".bright_white
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
```rb
|
|
205
|
+
puts "hello".green.bold.italic
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
## Advanced usage
|
|
209
|
+
|
|
210
|
+
```sh
|
|
211
|
+
RUNFILE=/path/to/Runfile.rb run my_task
|
|
212
|
+
```
|
data/src/bootstrap.rb
CHANGED
|
@@ -77,6 +77,12 @@ task :publish do
|
|
|
77
77
|
`rm #{gemspec.name}-#{gemspec.version}.gem`
|
|
78
78
|
end
|
|
79
79
|
|
|
80
|
+
# Display the manual.
|
|
81
|
+
task :man do
|
|
82
|
+
command = exists("bat") ? "bat" : "cat"
|
|
83
|
+
run "#{command} #{__dir__}/../CHEATSHEET.md"
|
|
84
|
+
end
|
|
85
|
+
|
|
80
86
|
# Expose helpers.
|
|
81
87
|
Dir.glob(File.join(__dir__, "run", "helper", "*.rb")) do |path|
|
|
82
88
|
filename = File.basename(path, ".rb")
|
|
@@ -5,7 +5,7 @@ module Run
|
|
|
5
5
|
class AreYouSureHelper
|
|
6
6
|
# @param message [String]
|
|
7
7
|
def initialize(message = "Are you sure?")
|
|
8
|
-
raise ArgumentError.new("'message' must be a String")
|
|
8
|
+
raise ArgumentError.new("'message' must be a String") unless message.is_a?(String)
|
|
9
9
|
@message = message
|
|
10
10
|
end
|
|
11
11
|
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Run
|
|
4
|
+
module Helper
|
|
5
|
+
class ExistsHelper
|
|
6
|
+
# @param program [String]
|
|
7
|
+
def initialize(program)
|
|
8
|
+
raise ArgumentError.new("'program' must be a String") unless program.is_a?(String)
|
|
9
|
+
|
|
10
|
+
@program = program
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
# @return [Boolean]
|
|
14
|
+
def run
|
|
15
|
+
system("which", @program, out: File::NULL, err: File::NULL)
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: run_tasks
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.1
|
|
4
|
+
version: 3.2.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Aurélien Delogu
|
|
@@ -71,6 +71,7 @@ executables:
|
|
|
71
71
|
extensions: []
|
|
72
72
|
extra_rdoc_files: []
|
|
73
73
|
files:
|
|
74
|
+
- CHEATSHEET.md
|
|
74
75
|
- bin/run
|
|
75
76
|
- completions/_run
|
|
76
77
|
- src/bootstrap.rb
|
|
@@ -86,6 +87,7 @@ files:
|
|
|
86
87
|
- src/run/helper/are_you_sure_helper.rb
|
|
87
88
|
- src/run/helper/bind_helper.rb
|
|
88
89
|
- src/run/helper/catch_interruption_helper.rb
|
|
90
|
+
- src/run/helper/exists_helper.rb
|
|
89
91
|
- src/run/helper/expand_helper.rb
|
|
90
92
|
- src/run/helper/menu_helper.rb
|
|
91
93
|
- src/run/helper/pause_helper.rb
|