run_tasks 3.2.0 → 3.2.3

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 (4) hide show
  1. checksums.yaml +4 -4
  2. data/CHEATSHEET.md +218 -0
  3. data/src/bootstrap.rb +1 -2
  4. metadata +2 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f162dd89c96e5d57659848493488f2b9f02337f169d01077e1b58554142efb32
4
- data.tar.gz: f6c6316654baf6399507b90f144c4fbbc5c50e66e430242e36fc791d2aaa0080
3
+ metadata.gz: d9e8f32ee31f48e5f7d451f2b956faac1881b4a1a20b40de21eb02a32831a7ad
4
+ data.tar.gz: dd121f1d5f725e9497fe05a3b04423415f65c1621f53ba9f59a9c453b4569c7e
5
5
  SHA512:
6
- metadata.gz: c9f6edcb2af5b824bad3c59f7f649664152a95347edd341e7de96ff4e0c613bdee171d06f04e3bede97f8b81c4c0042d97192f71821a9f6d252b4fd342b0296d
7
- data.tar.gz: a041c5d2b79f74550443cca60b2a0901bb2f0a38de20e2f09b00cede5472ec4ac3a56bf79de7d8b677f683e49d0fab7d4f37148c474c869328f5fa6c128e40f2
6
+ metadata.gz: fe92ecc38071af0a6b80ed2e98288c308a6c191dd95a5610f6039672f5a4f25ae61d6dc3b5cceb0b78e1bae30f61f9f9f00848cadc15b061b909403dd14fc809
7
+ data.tar.gz: d022b3de66d9d7642b76ec7a852dc427e4ca67244f1fbc0cca5d9d0449bd4d5f6c8331892a6dcbad37b708239c0a406bbd84078023f3bd82c15a4a9ad2be2d0c
data/CHEATSHEET.md ADDED
@@ -0,0 +1,218 @@
1
+ # Defining a task
2
+
3
+ ```rb
4
+ task :eslint do
5
+ end
6
+ ```
7
+
8
+ # Defining a task with aliases
9
+
10
+ ```rb
11
+ task [:console, :c] do
12
+ end
13
+ ```
14
+
15
+ # Defining a task with parameters
16
+
17
+ ```rb
18
+ task :hello do |name, age|
19
+ puts "Hello #{name}, you are #{age}."
20
+ end
21
+ ```
22
+
23
+ # Running commands
24
+
25
+ ```rb
26
+ task :clear_all do
27
+ run "rm -rf /*"
28
+ end
29
+ ```
30
+
31
+ # Running subtasks
32
+
33
+ ```rb
34
+ task :linting do
35
+ run :eslint
36
+ run :rubocop
37
+ end
38
+ ```
39
+
40
+ # Running a task/command in quiet mode
41
+
42
+ ```rb
43
+ task :clear_cache do
44
+ run "rm -rf cache/*", quiet: true
45
+ end
46
+ ```
47
+
48
+ # Using named booleans
49
+
50
+ ```sh
51
+ run server +tunnel
52
+ ```
53
+
54
+ ```rb
55
+ task :server do |tunnel: false|
56
+ run "http_server #{tunnel ? "--tunnel" : ""}"
57
+ end
58
+ ```
59
+
60
+ # Helpers
61
+
62
+ ## are_you_sure
63
+
64
+ ```rb
65
+ task :dangerous_task do
66
+ are_you_sure "This task will delete your hard drive. Are you sure about that?"
67
+ # Some dangerous actions.
68
+ end
69
+ ```
70
+
71
+ ## bind
72
+
73
+ ```rb
74
+ task :rails do
75
+ run "bundle exec unicorn -c config/unicorn.rb -p 3000"
76
+ end
77
+
78
+ task :vite do
79
+ run "bin/vite dev"
80
+ end
81
+
82
+ task :dev do
83
+ # Bind `rails` and `vite` tasks together, if one closes, the other terminates too.
84
+ bind :rails, :vite
85
+ end
86
+ ```
87
+
88
+ ```rb
89
+ task :dev do
90
+ # Plug STDIN to the `rails` task.
91
+ bind :rails, :vite, stdin: :rails
92
+ end
93
+ ```
94
+
95
+ ## catch_interruption
96
+
97
+ ```rb
98
+ task :server do
99
+ catch_interruption("docker run -d -p 8080:80 web_server") do
100
+ run :clear_cache
101
+ end
102
+ end
103
+ ```
104
+
105
+ ## exists
106
+
107
+ ```rb
108
+ task :man do
109
+ command = exists("bat") ? "bat" : "cat"
110
+ run "#{command} #{__dir__}/README.md"
111
+ end
112
+ ```
113
+
114
+ ## expand
115
+
116
+ ```rb
117
+ task :scan do |glob|
118
+ expand(glob).each do |file_path|
119
+ puts file_path
120
+ end
121
+ end
122
+ ```
123
+
124
+ ## menu
125
+
126
+ ```rb
127
+ task :deploy_aws do
128
+ region = menu "Location?", ["us‑east‑2", "us-west-1", "eu-west-1"]
129
+ end
130
+ ```
131
+
132
+ ```rb
133
+ task :deploy_aws do
134
+ region = menu "Location?", {
135
+ "US East (Ohio)" => "us‑east‑2",
136
+ "US West (N. California)" => "us-west-1",
137
+ "Europe (Ireland)" => "eu-west-1",
138
+ }
139
+ end
140
+ ```
141
+
142
+ ## pause
143
+
144
+ ```rb
145
+ task :deploy do
146
+ puts "Press enter to continue.".yellow
147
+ pause
148
+ run :deploy_production
149
+ end
150
+ ```
151
+
152
+ ## question
153
+
154
+ ```rb
155
+ task :survey do
156
+ comment = question "Did your meal was good?"
157
+ end
158
+ ```
159
+
160
+ ```rb
161
+ task :age do
162
+ age = question "What is your age?", /^\d+$/
163
+ end
164
+ ```
165
+
166
+ ## wait_for_interruption
167
+
168
+ ```rb
169
+ task :server do
170
+ Thread.new do
171
+ run :rails
172
+ end
173
+ Thread.new do
174
+ run :vite
175
+ end
176
+ wait_for_interruption do
177
+ run :kill_rails
178
+ run :kill_vite
179
+ end
180
+ end
181
+ ```
182
+
183
+ # Colorization
184
+
185
+ ```rb
186
+ puts "hello".bold
187
+ puts "hello".dim
188
+ puts "hello".italic
189
+ puts "hello".underline
190
+ puts "hello".inverse
191
+ puts "hello".strikethrough
192
+ puts "hello".black
193
+ puts "hello".red
194
+ puts "hello".green
195
+ puts "hello".yellow
196
+ puts "hello".blue
197
+ puts "hello".magenta
198
+ puts "hello".cyan
199
+ puts "hello".white
200
+ puts "hello".bright_black
201
+ puts "hello".bright_red
202
+ puts "hello".bright_green
203
+ puts "hello".bright_yellow
204
+ puts "hello".bright_blue
205
+ puts "hello".bright_magenta
206
+ puts "hello".bright_cyan
207
+ puts "hello".bright_white
208
+ ```
209
+
210
+ ```rb
211
+ puts "hello".green.bold.italic
212
+ ```
213
+
214
+ # Advanced usage
215
+
216
+ ```sh
217
+ RUNFILE=/path/to/Runfile.rb run my_task
218
+ ```
data/src/bootstrap.rb CHANGED
@@ -79,8 +79,7 @@ end
79
79
 
80
80
  # Display the manual.
81
81
  task :man do
82
- command = exists("bat") ? "bat" : "cat"
83
- run "#{command} #{__dir__}/../CHEATSHEET.md"
82
+ puts Markdown::Engine.new(File.read("#{__dir__}/../CHEATSHEET.md")).to_ansi
84
83
  end
85
84
 
86
85
  # Expose helpers.
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.2.0
4
+ version: 3.2.3
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