command_kit 0.2.2 → 0.4.0
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/.github/workflows/ruby.yml +4 -5
- data/.rubocop.yml +14 -1
- data/ChangeLog.md +82 -0
- data/Gemfile +2 -0
- data/LICENSE.txt +1 -1
- data/README.md +18 -9
- data/command_kit.gemspec +0 -1
- data/examples/printing/tables.rb +141 -0
- data/gemspec.yml +3 -3
- data/lib/command_kit/arguments/argument.rb +2 -2
- data/lib/command_kit/arguments.rb +27 -2
- data/lib/command_kit/bug_report.rb +105 -0
- data/lib/command_kit/colors.rb +488 -15
- data/lib/command_kit/command.rb +1 -2
- data/lib/command_kit/edit.rb +54 -0
- data/lib/command_kit/env.rb +1 -1
- data/lib/command_kit/file_utils.rb +46 -0
- data/lib/command_kit/options/option.rb +45 -22
- data/lib/command_kit/options/option_value.rb +2 -2
- data/lib/command_kit/options/parser.rb +1 -4
- data/lib/command_kit/options/quiet.rb +1 -1
- data/lib/command_kit/options/verbose.rb +2 -2
- data/lib/command_kit/options/version.rb +10 -0
- data/lib/command_kit/options.rb +89 -14
- data/lib/command_kit/os.rb +1 -1
- data/lib/command_kit/printing/fields.rb +56 -0
- data/lib/command_kit/printing/indent.rb +1 -1
- data/lib/command_kit/printing/lists.rb +91 -0
- data/lib/command_kit/printing/tables/border_style.rb +169 -0
- data/lib/command_kit/printing/tables/cell_builder.rb +93 -0
- data/lib/command_kit/printing/tables/row_builder.rb +111 -0
- data/lib/command_kit/printing/tables/style.rb +198 -0
- data/lib/command_kit/printing/tables/table_builder.rb +145 -0
- data/lib/command_kit/printing/tables/table_formatter.rb +254 -0
- data/lib/command_kit/printing/tables.rb +208 -0
- data/lib/command_kit/program_name.rb +9 -0
- data/lib/command_kit/stdio.rb +5 -1
- data/lib/command_kit/version.rb +1 -1
- data/spec/arguments_spec.rb +33 -0
- data/spec/bug_report_spec.rb +266 -0
- data/spec/colors_spec.rb +232 -195
- data/spec/command_name_spec.rb +1 -1
- data/spec/command_spec.rb +2 -2
- data/spec/edit_spec.rb +72 -0
- data/spec/file_utils_spec.rb +59 -0
- data/spec/fixtures/template.erb +5 -0
- data/spec/options/option_spec.rb +48 -2
- data/spec/options/parser_spec.rb +0 -10
- data/spec/options/quiet_spec.rb +51 -0
- data/spec/options/verbose_spec.rb +51 -0
- data/spec/options/version_spec.rb +146 -0
- data/spec/options_spec.rb +46 -0
- data/spec/pager_spec.rb +1 -1
- data/spec/printing/fields_spec.rb +167 -0
- data/spec/printing/lists_spec.rb +99 -0
- data/spec/printing/tables/border_style.rb +43 -0
- data/spec/printing/tables/cell_builer_spec.rb +135 -0
- data/spec/printing/tables/row_builder_spec.rb +165 -0
- data/spec/printing/tables/style_spec.rb +377 -0
- data/spec/printing/tables/table_builder_spec.rb +252 -0
- data/spec/printing/tables/table_formatter_spec.rb +1180 -0
- data/spec/printing/tables_spec.rb +1069 -0
- data/spec/program_name_spec.rb +8 -0
- metadata +36 -7
data/spec/colors_spec.rb
CHANGED
@@ -65,6 +65,38 @@ describe CommandKit::Colors do
|
|
65
65
|
it { expect(subject::WHITE).to eq("\e[37m") }
|
66
66
|
end
|
67
67
|
|
68
|
+
describe "BRIGHT_BLACK" do
|
69
|
+
it { expect(subject::BRIGHT_BLACK).to eq("\e[90m") }
|
70
|
+
end
|
71
|
+
|
72
|
+
describe "BRIGHT_RED" do
|
73
|
+
it { expect(subject::BRIGHT_RED).to eq("\e[91m") }
|
74
|
+
end
|
75
|
+
|
76
|
+
describe "BRIGHT_GREEN" do
|
77
|
+
it { expect(subject::BRIGHT_GREEN).to eq("\e[92m") }
|
78
|
+
end
|
79
|
+
|
80
|
+
describe "BRIGHT_YELLOW" do
|
81
|
+
it { expect(subject::BRIGHT_YELLOW).to eq("\e[93m") }
|
82
|
+
end
|
83
|
+
|
84
|
+
describe "BRIGHT_BLUE" do
|
85
|
+
it { expect(subject::BRIGHT_BLUE).to eq("\e[94m") }
|
86
|
+
end
|
87
|
+
|
88
|
+
describe "BRIGHT_MAGENTA" do
|
89
|
+
it { expect(subject::BRIGHT_MAGENTA).to eq("\e[95m") }
|
90
|
+
end
|
91
|
+
|
92
|
+
describe "BRIGHT_CYAN" do
|
93
|
+
it { expect(subject::BRIGHT_CYAN).to eq("\e[96m") }
|
94
|
+
end
|
95
|
+
|
96
|
+
describe "BRIGHT_WHITE" do
|
97
|
+
it { expect(subject::BRIGHT_WHITE).to eq("\e[97m") }
|
98
|
+
end
|
99
|
+
|
68
100
|
describe "ON_BLACK" do
|
69
101
|
it { expect(subject::ON_BLACK).to eq("\e[40m") }
|
70
102
|
end
|
@@ -97,6 +129,42 @@ describe CommandKit::Colors do
|
|
97
129
|
it { expect(subject::ON_WHITE).to eq("\e[47m") }
|
98
130
|
end
|
99
131
|
|
132
|
+
describe "ON_BRIGHT_BLACK" do
|
133
|
+
it { expect(subject::ON_BRIGHT_BLACK).to eq("\e[100m") }
|
134
|
+
end
|
135
|
+
|
136
|
+
describe "ON_BRIGHT_RED" do
|
137
|
+
it { expect(subject::ON_BRIGHT_RED).to eq("\e[101m") }
|
138
|
+
end
|
139
|
+
|
140
|
+
describe "ON_BRIGHT_GREEN" do
|
141
|
+
it { expect(subject::ON_BRIGHT_GREEN).to eq("\e[102m") }
|
142
|
+
end
|
143
|
+
|
144
|
+
describe "ON_BRIGHT_YELLOW" do
|
145
|
+
it { expect(subject::ON_BRIGHT_YELLOW).to eq("\e[103m") }
|
146
|
+
end
|
147
|
+
|
148
|
+
describe "ON_BRIGHT_BLUE" do
|
149
|
+
it { expect(subject::ON_BRIGHT_BLUE).to eq("\e[104m") }
|
150
|
+
end
|
151
|
+
|
152
|
+
describe "ON_BRIGHT_MAGENTA" do
|
153
|
+
it { expect(subject::ON_BRIGHT_MAGENTA).to eq("\e[105m") }
|
154
|
+
end
|
155
|
+
|
156
|
+
describe "ON_BRIGHT_CYAN" do
|
157
|
+
it { expect(subject::ON_BRIGHT_CYAN).to eq("\e[106m") }
|
158
|
+
end
|
159
|
+
|
160
|
+
describe "ON_BRIGHT_WHITE" do
|
161
|
+
it { expect(subject::ON_BRIGHT_WHITE).to eq("\e[107m") }
|
162
|
+
end
|
163
|
+
|
164
|
+
describe "RESET_FG" do
|
165
|
+
it { expect(subject::RESET_FG).to eq("\e[39m") }
|
166
|
+
end
|
167
|
+
|
100
168
|
describe "RESET_COLOR" do
|
101
169
|
it { expect(subject::RESET_COLOR).to eq("\e[39m") }
|
102
170
|
end
|
@@ -219,401 +287,364 @@ describe CommandKit::Colors do
|
|
219
287
|
end
|
220
288
|
end
|
221
289
|
|
222
|
-
describe ".
|
290
|
+
describe ".bright_black" do
|
223
291
|
context "when given a string" do
|
224
|
-
it "must wrap the string with \\e[
|
225
|
-
expect(subject.
|
292
|
+
it "must wrap the string with \\e[90m and \\e[39m" do
|
293
|
+
expect(subject.bright_black(str)).to eq("\e[90m#{str}\e[39m")
|
226
294
|
end
|
227
295
|
end
|
228
296
|
|
229
297
|
context "when given no arguments" do
|
230
|
-
it { expect(subject.
|
298
|
+
it { expect(subject.bright_black).to eq("\e[90m") }
|
231
299
|
end
|
232
300
|
end
|
233
301
|
|
234
|
-
describe ".
|
302
|
+
describe ".gray" do
|
235
303
|
context "when given a string" do
|
236
|
-
it "must wrap the string with \\e[
|
237
|
-
expect(subject.
|
304
|
+
it "must wrap the string with \\e[90m and \\e[39m" do
|
305
|
+
expect(subject.gray(str)).to eq("\e[90m#{str}\e[39m")
|
238
306
|
end
|
239
307
|
end
|
240
308
|
|
241
309
|
context "when given no arguments" do
|
242
|
-
it { expect(subject.
|
310
|
+
it { expect(subject.gray).to eq("\e[90m") }
|
243
311
|
end
|
244
312
|
end
|
245
313
|
|
246
|
-
describe ".
|
314
|
+
describe ".bright_red" do
|
247
315
|
context "when given a string" do
|
248
|
-
it "must wrap the string with \\e[
|
249
|
-
expect(subject.
|
316
|
+
it "must wrap the string with \\e[91m and \\e[39m" do
|
317
|
+
expect(subject.bright_red(str)).to eq("\e[91m#{str}\e[39m")
|
250
318
|
end
|
251
319
|
end
|
252
320
|
|
253
321
|
context "when given no arguments" do
|
254
|
-
it { expect(subject.
|
322
|
+
it { expect(subject.bright_red).to eq("\e[91m") }
|
255
323
|
end
|
256
324
|
end
|
257
325
|
|
258
|
-
describe ".
|
326
|
+
describe ".bright_green" do
|
259
327
|
context "when given a string" do
|
260
|
-
it "must wrap the string with \\e[
|
261
|
-
expect(subject.
|
328
|
+
it "must wrap the string with \\e[92m and \\e[39m" do
|
329
|
+
expect(subject.bright_green(str)).to eq("\e[92m#{str}\e[39m")
|
262
330
|
end
|
263
331
|
end
|
264
332
|
|
265
333
|
context "when given no arguments" do
|
266
|
-
it { expect(subject.
|
334
|
+
it { expect(subject.bright_green).to eq("\e[92m") }
|
267
335
|
end
|
268
336
|
end
|
269
337
|
|
270
|
-
describe ".
|
338
|
+
describe ".bright_yellow" do
|
271
339
|
context "when given a string" do
|
272
|
-
it "must wrap the string with \\e[
|
273
|
-
expect(subject.
|
340
|
+
it "must wrap the string with \\e[93m and \\e[39m" do
|
341
|
+
expect(subject.bright_yellow(str)).to eq("\e[93m#{str}\e[39m")
|
274
342
|
end
|
275
343
|
end
|
276
344
|
|
277
345
|
context "when given no arguments" do
|
278
|
-
it { expect(subject.
|
346
|
+
it { expect(subject.bright_yellow).to eq("\e[93m") }
|
279
347
|
end
|
280
348
|
end
|
281
349
|
|
282
|
-
describe ".
|
350
|
+
describe ".bright_blue" do
|
283
351
|
context "when given a string" do
|
284
|
-
it "must wrap the string with \\e[
|
285
|
-
expect(subject.
|
352
|
+
it "must wrap the string with \\e[94m and \\e[39m" do
|
353
|
+
expect(subject.bright_blue(str)).to eq("\e[94m#{str}\e[39m")
|
286
354
|
end
|
287
355
|
end
|
288
356
|
|
289
357
|
context "when given no arguments" do
|
290
|
-
it { expect(subject.
|
358
|
+
it { expect(subject.bright_blue).to eq("\e[94m") }
|
291
359
|
end
|
292
360
|
end
|
293
361
|
|
294
|
-
describe ".
|
362
|
+
describe ".bright_magenta" do
|
295
363
|
context "when given a string" do
|
296
|
-
it "must wrap the string with \\e[
|
297
|
-
expect(subject.
|
364
|
+
it "must wrap the string with \\e[95m and \\e[39m" do
|
365
|
+
expect(subject.bright_magenta(str)).to eq("\e[95m#{str}\e[39m")
|
298
366
|
end
|
299
367
|
end
|
300
368
|
|
301
369
|
context "when given no arguments" do
|
302
|
-
it { expect(subject.
|
370
|
+
it { expect(subject.bright_magenta).to eq("\e[95m") }
|
303
371
|
end
|
304
372
|
end
|
305
373
|
|
306
|
-
describe ".
|
374
|
+
describe ".bright_cyan" do
|
307
375
|
context "when given a string" do
|
308
|
-
it "must wrap the string with \\e[
|
309
|
-
expect(subject.
|
376
|
+
it "must wrap the string with \\e[96m and \\e[39m" do
|
377
|
+
expect(subject.bright_cyan(str)).to eq("\e[96m#{str}\e[39m")
|
310
378
|
end
|
311
379
|
end
|
312
380
|
|
313
381
|
context "when given no arguments" do
|
314
|
-
it { expect(subject.
|
382
|
+
it { expect(subject.bright_cyan).to eq("\e[96m") }
|
315
383
|
end
|
316
384
|
end
|
317
|
-
end
|
318
|
-
|
319
|
-
describe CommandKit::Colors::PlainText do
|
320
|
-
subject { described_class }
|
321
|
-
|
322
|
-
let(:str) { 'foo' }
|
323
|
-
|
324
|
-
describe "RESET" do
|
325
|
-
it { expect(subject::RESET).to eq('') }
|
326
|
-
end
|
327
|
-
|
328
|
-
describe "CLEAR" do
|
329
|
-
it { expect(subject::CLEAR).to eq('') }
|
330
|
-
end
|
331
|
-
|
332
|
-
describe "BOLD" do
|
333
|
-
it { expect(subject::BOLD).to eq('') }
|
334
|
-
end
|
335
|
-
|
336
|
-
describe "RESET_INTENSITY" do
|
337
|
-
it { expect(subject::RESET_INTENSITY).to eq('') }
|
338
|
-
end
|
339
|
-
|
340
|
-
describe "BLACK" do
|
341
|
-
it { expect(subject::BLACK).to eq('') }
|
342
|
-
end
|
343
|
-
|
344
|
-
describe "RED" do
|
345
|
-
it { expect(subject::RED).to eq('') }
|
346
|
-
end
|
347
|
-
|
348
|
-
describe "GREEN" do
|
349
|
-
it { expect(subject::GREEN).to eq('') }
|
350
|
-
end
|
351
|
-
|
352
|
-
describe "YELLOW" do
|
353
|
-
it { expect(subject::YELLOW).to eq('') }
|
354
|
-
end
|
355
|
-
|
356
|
-
describe "BLUE" do
|
357
|
-
it { expect(subject::BLUE).to eq('') }
|
358
|
-
end
|
359
|
-
|
360
|
-
describe "MAGENTA" do
|
361
|
-
it { expect(subject::MAGENTA).to eq('') }
|
362
|
-
end
|
363
|
-
|
364
|
-
describe "CYAN" do
|
365
|
-
it { expect(subject::CYAN).to eq('') }
|
366
|
-
end
|
367
|
-
|
368
|
-
describe "WHITE" do
|
369
|
-
it { expect(subject::WHITE).to eq('') }
|
370
|
-
end
|
371
|
-
|
372
|
-
describe "ON_BLACK" do
|
373
|
-
it { expect(subject::ON_BLACK).to eq('') }
|
374
|
-
end
|
375
385
|
|
376
|
-
describe "
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
end
|
383
|
-
|
384
|
-
describe "ON_YELLOW" do
|
385
|
-
it { expect(subject::ON_YELLOW).to eq('') }
|
386
|
-
end
|
387
|
-
|
388
|
-
describe "ON_BLUE" do
|
389
|
-
it { expect(subject::ON_BLUE).to eq('') }
|
390
|
-
end
|
391
|
-
|
392
|
-
describe "ON_MAGENTA" do
|
393
|
-
it { expect(subject::ON_MAGENTA).to eq('') }
|
394
|
-
end
|
395
|
-
|
396
|
-
describe "ON_CYAN" do
|
397
|
-
it { expect(subject::ON_CYAN).to eq('') }
|
398
|
-
end
|
399
|
-
|
400
|
-
describe "ON_WHITE" do
|
401
|
-
it { expect(subject::ON_WHITE).to eq('') }
|
402
|
-
end
|
403
|
-
|
404
|
-
describe "RESET_COLOR" do
|
405
|
-
it { expect(subject::RESET_COLOR).to eq('') }
|
406
|
-
end
|
407
|
-
|
408
|
-
describe ".reset" do
|
409
|
-
it { expect(subject.reset).to eq('') }
|
410
|
-
end
|
386
|
+
describe ".bright_white" do
|
387
|
+
context "when given a string" do
|
388
|
+
it "must wrap the string with \\e[97m and \\e[39m" do
|
389
|
+
expect(subject.bright_white(str)).to eq("\e[97m#{str}\e[39m")
|
390
|
+
end
|
391
|
+
end
|
411
392
|
|
412
|
-
|
413
|
-
|
393
|
+
context "when given no arguments" do
|
394
|
+
it { expect(subject.bright_white).to eq("\e[97m") }
|
395
|
+
end
|
414
396
|
end
|
415
397
|
|
416
|
-
describe ".
|
398
|
+
describe ".on_black" do
|
417
399
|
context "when given a string" do
|
418
|
-
it "must
|
419
|
-
expect(subject.
|
400
|
+
it "must wrap the string with \\e[40m and \\e[39m" do
|
401
|
+
expect(subject.on_black(str)).to eq("\e[40m#{str}\e[49m")
|
420
402
|
end
|
421
403
|
end
|
422
404
|
|
423
405
|
context "when given no arguments" do
|
424
|
-
it { expect(subject.
|
406
|
+
it { expect(subject.on_black).to eq("\e[40m") }
|
425
407
|
end
|
426
408
|
end
|
427
409
|
|
428
|
-
describe ".
|
410
|
+
describe ".on_red" do
|
429
411
|
context "when given a string" do
|
430
|
-
it "must
|
431
|
-
expect(subject.
|
412
|
+
it "must wrap the string with \\e[41m and \\e[39m" do
|
413
|
+
expect(subject.on_red(str)).to eq("\e[41m#{str}\e[49m")
|
432
414
|
end
|
433
415
|
end
|
434
416
|
|
435
417
|
context "when given no arguments" do
|
436
|
-
it { expect(subject.
|
418
|
+
it { expect(subject.on_red).to eq("\e[41m") }
|
437
419
|
end
|
438
420
|
end
|
439
421
|
|
440
|
-
describe ".
|
422
|
+
describe ".on_green" do
|
441
423
|
context "when given a string" do
|
442
|
-
it "must
|
443
|
-
expect(subject.
|
424
|
+
it "must wrap the string with \\e[42m and \\e[39m" do
|
425
|
+
expect(subject.on_green(str)).to eq("\e[42m#{str}\e[49m")
|
444
426
|
end
|
445
427
|
end
|
446
428
|
|
447
429
|
context "when given no arguments" do
|
448
|
-
it { expect(subject.
|
430
|
+
it { expect(subject.on_green).to eq("\e[42m") }
|
449
431
|
end
|
450
432
|
end
|
451
433
|
|
452
|
-
describe ".
|
434
|
+
describe ".on_yellow" do
|
453
435
|
context "when given a string" do
|
454
|
-
it "must
|
455
|
-
expect(subject.
|
436
|
+
it "must wrap the string with \\e[43m and \\e[39m" do
|
437
|
+
expect(subject.on_yellow(str)).to eq("\e[43m#{str}\e[49m")
|
456
438
|
end
|
457
439
|
end
|
458
440
|
|
459
441
|
context "when given no arguments" do
|
460
|
-
it { expect(subject.
|
442
|
+
it { expect(subject.on_yellow).to eq("\e[43m") }
|
461
443
|
end
|
462
444
|
end
|
463
445
|
|
464
|
-
describe ".
|
446
|
+
describe ".on_blue" do
|
465
447
|
context "when given a string" do
|
466
|
-
it "must
|
467
|
-
expect(subject.
|
448
|
+
it "must wrap the string with \\e[44m and \\e[39m" do
|
449
|
+
expect(subject.on_blue(str)).to eq("\e[44m#{str}\e[49m")
|
468
450
|
end
|
469
451
|
end
|
470
452
|
|
471
453
|
context "when given no arguments" do
|
472
|
-
it { expect(subject.
|
454
|
+
it { expect(subject.on_blue).to eq("\e[44m") }
|
473
455
|
end
|
474
456
|
end
|
475
457
|
|
476
|
-
describe ".
|
458
|
+
describe ".on_magenta" do
|
477
459
|
context "when given a string" do
|
478
|
-
it "must
|
479
|
-
expect(subject.
|
460
|
+
it "must wrap the string with \\e[45m and \\e[39m" do
|
461
|
+
expect(subject.on_magenta(str)).to eq("\e[45m#{str}\e[49m")
|
480
462
|
end
|
481
463
|
end
|
482
464
|
|
483
465
|
context "when given no arguments" do
|
484
|
-
it { expect(subject.
|
466
|
+
it { expect(subject.on_magenta).to eq("\e[45m") }
|
485
467
|
end
|
486
468
|
end
|
487
469
|
|
488
|
-
describe ".
|
470
|
+
describe ".on_cyan" do
|
489
471
|
context "when given a string" do
|
490
|
-
it "must
|
491
|
-
expect(subject.
|
472
|
+
it "must wrap the string with \\e[46m and \\e[39m" do
|
473
|
+
expect(subject.on_cyan(str)).to eq("\e[46m#{str}\e[49m")
|
492
474
|
end
|
493
475
|
end
|
494
476
|
|
495
477
|
context "when given no arguments" do
|
496
|
-
it { expect(subject.
|
478
|
+
it { expect(subject.on_cyan).to eq("\e[46m") }
|
497
479
|
end
|
498
480
|
end
|
499
481
|
|
500
|
-
describe ".
|
482
|
+
describe ".on_white" do
|
501
483
|
context "when given a string" do
|
502
|
-
it "must
|
503
|
-
expect(subject.
|
484
|
+
it "must wrap the string with \\e[47m and \\e[39m" do
|
485
|
+
expect(subject.on_white(str)).to eq("\e[47m#{str}\e[49m")
|
504
486
|
end
|
505
487
|
end
|
506
488
|
|
507
489
|
context "when given no arguments" do
|
508
|
-
it { expect(subject.
|
490
|
+
it { expect(subject.on_white).to eq("\e[47m") }
|
509
491
|
end
|
510
492
|
end
|
511
493
|
|
512
|
-
describe ".
|
494
|
+
describe ".on_bright_black" do
|
513
495
|
context "when given a string" do
|
514
|
-
it "must
|
515
|
-
expect(subject.
|
496
|
+
it "must wrap the string with \\e[100m and \\e[39m" do
|
497
|
+
expect(subject.on_bright_black(str)).to eq("\e[100m#{str}\e[49m")
|
516
498
|
end
|
517
499
|
end
|
518
500
|
|
519
501
|
context "when given no arguments" do
|
520
|
-
it { expect(subject.
|
502
|
+
it { expect(subject.on_bright_black).to eq("\e[100m") }
|
521
503
|
end
|
522
504
|
end
|
523
505
|
|
524
|
-
describe ".
|
506
|
+
describe ".on_gray" do
|
525
507
|
context "when given a string" do
|
526
|
-
it "must
|
527
|
-
expect(subject.
|
508
|
+
it "must wrap the string with \\e[100m and \\e[39m" do
|
509
|
+
expect(subject.on_gray(str)).to eq("\e[100m#{str}\e[49m")
|
528
510
|
end
|
529
511
|
end
|
530
512
|
|
531
513
|
context "when given no arguments" do
|
532
|
-
it { expect(subject.
|
514
|
+
it { expect(subject.on_gray).to eq("\e[100m") }
|
533
515
|
end
|
534
516
|
end
|
535
517
|
|
536
|
-
describe ".
|
518
|
+
describe ".on_bright_red" do
|
537
519
|
context "when given a string" do
|
538
|
-
it "must
|
539
|
-
expect(subject.
|
520
|
+
it "must wrap the string with \\e[101m and \\e[39m" do
|
521
|
+
expect(subject.on_bright_red(str)).to eq("\e[101m#{str}\e[49m")
|
540
522
|
end
|
541
523
|
end
|
542
524
|
|
543
525
|
context "when given no arguments" do
|
544
|
-
it { expect(subject.
|
526
|
+
it { expect(subject.on_bright_red).to eq("\e[101m") }
|
545
527
|
end
|
546
528
|
end
|
547
529
|
|
548
|
-
describe ".
|
530
|
+
describe ".on_bright_green" do
|
549
531
|
context "when given a string" do
|
550
|
-
it "must
|
551
|
-
expect(subject.
|
532
|
+
it "must wrap the string with \\e[102m and \\e[39m" do
|
533
|
+
expect(subject.on_bright_green(str)).to eq("\e[102m#{str}\e[49m")
|
552
534
|
end
|
553
535
|
end
|
554
536
|
|
555
537
|
context "when given no arguments" do
|
556
|
-
it { expect(subject.
|
538
|
+
it { expect(subject.on_bright_green).to eq("\e[102m") }
|
557
539
|
end
|
558
540
|
end
|
559
541
|
|
560
|
-
describe ".
|
542
|
+
describe ".on_bright_yellow" do
|
561
543
|
context "when given a string" do
|
562
|
-
it "must
|
563
|
-
expect(subject.
|
544
|
+
it "must wrap the string with \\e[103m and \\e[39m" do
|
545
|
+
expect(subject.on_bright_yellow(str)).to eq("\e[103m#{str}\e[49m")
|
564
546
|
end
|
565
547
|
end
|
566
548
|
|
567
549
|
context "when given no arguments" do
|
568
|
-
it { expect(subject.
|
550
|
+
it { expect(subject.on_bright_yellow).to eq("\e[103m") }
|
569
551
|
end
|
570
552
|
end
|
571
553
|
|
572
|
-
describe ".
|
554
|
+
describe ".on_bright_blue" do
|
573
555
|
context "when given a string" do
|
574
|
-
it "must
|
575
|
-
expect(subject.
|
556
|
+
it "must wrap the string with \\e[104m and \\e[39m" do
|
557
|
+
expect(subject.on_bright_blue(str)).to eq("\e[104m#{str}\e[49m")
|
576
558
|
end
|
577
559
|
end
|
578
560
|
|
579
561
|
context "when given no arguments" do
|
580
|
-
it { expect(subject.
|
562
|
+
it { expect(subject.on_bright_blue).to eq("\e[104m") }
|
581
563
|
end
|
582
564
|
end
|
583
565
|
|
584
|
-
describe ".
|
566
|
+
describe ".on_bright_magenta" do
|
585
567
|
context "when given a string" do
|
586
|
-
it "must
|
587
|
-
expect(subject.
|
568
|
+
it "must wrap the string with \\e[105m and \\e[39m" do
|
569
|
+
expect(subject.on_bright_magenta(str)).to eq("\e[105m#{str}\e[49m")
|
588
570
|
end
|
589
571
|
end
|
590
572
|
|
591
573
|
context "when given no arguments" do
|
592
|
-
it { expect(subject.
|
574
|
+
it { expect(subject.on_bright_magenta).to eq("\e[105m") }
|
593
575
|
end
|
594
576
|
end
|
595
577
|
|
596
|
-
describe ".
|
578
|
+
describe ".on_bright_cyan" do
|
597
579
|
context "when given a string" do
|
598
|
-
it "must
|
599
|
-
expect(subject.
|
580
|
+
it "must wrap the string with \\e[106m and \\e[39m" do
|
581
|
+
expect(subject.on_bright_cyan(str)).to eq("\e[106m#{str}\e[49m")
|
600
582
|
end
|
601
583
|
end
|
602
584
|
|
603
585
|
context "when given no arguments" do
|
604
|
-
it { expect(subject.
|
586
|
+
it { expect(subject.on_bright_cyan).to eq("\e[106m") }
|
605
587
|
end
|
606
588
|
end
|
607
589
|
|
608
|
-
describe ".
|
590
|
+
describe ".on_bright_white" do
|
609
591
|
context "when given a string" do
|
610
|
-
it "must
|
611
|
-
expect(subject.
|
592
|
+
it "must wrap the string with \\e[107m and \\e[39m" do
|
593
|
+
expect(subject.on_bright_white(str)).to eq("\e[107m#{str}\e[49m")
|
612
594
|
end
|
613
595
|
end
|
614
596
|
|
615
597
|
context "when given no arguments" do
|
616
|
-
it { expect(subject.
|
598
|
+
it { expect(subject.on_bright_white).to eq("\e[107m") }
|
599
|
+
end
|
600
|
+
end
|
601
|
+
end
|
602
|
+
|
603
|
+
describe CommandKit::Colors::PlainText do
|
604
|
+
subject { described_class }
|
605
|
+
|
606
|
+
let(:str) { 'foo' }
|
607
|
+
|
608
|
+
[
|
609
|
+
:RESET, :CLEAR,
|
610
|
+
:BOLD, :RESET_INTENSITY,
|
611
|
+
:BLACK, :RED, :GREEN, :YELLOW, :BLUE, :MAGENTA, :CYAN, :WHITE,
|
612
|
+
:BRIGHT_BLACK, :BRIGHT_RED, :BRIGHT_GREEN, :BRIGHT_YELLOW, :BRIGHT_BLUE, :BRIGHT_MAGENTA, :BRIGHT_CYAN, :BRIGHT_WHITE,
|
613
|
+
:RESET_FG, :RESET_COLOR,
|
614
|
+
:ON_BLACK, :ON_RED, :ON_GREEN, :ON_YELLOW, :ON_BLUE, :ON_MAGENTA, :ON_CYAN, :ON_WHITE,
|
615
|
+
:ON_BRIGHT_BLACK, :ON_BRIGHT_RED, :ON_BRIGHT_GREEN, :ON_BRIGHT_YELLOW, :ON_BRIGHT_BLUE, :ON_BRIGHT_MAGENTA, :ON_BRIGHT_CYAN, :ON_BRIGHT_WHITE,
|
616
|
+
:RESET_BG
|
617
|
+
].each do |const_name|
|
618
|
+
describe const_name.to_s do
|
619
|
+
it { expect(subject.const_get(const_name)).to eq('') }
|
620
|
+
end
|
621
|
+
end
|
622
|
+
|
623
|
+
describe ".reset" do
|
624
|
+
it { expect(subject.reset).to eq('') }
|
625
|
+
end
|
626
|
+
|
627
|
+
describe ".clear" do
|
628
|
+
it { expect(subject.clear).to eq('') }
|
629
|
+
end
|
630
|
+
|
631
|
+
[
|
632
|
+
:bold,
|
633
|
+
:black, :red, :green, :yellow, :blue, :magenta, :cyan, :white,
|
634
|
+
:bright_black, :gray, :bright_red, :bright_green, :bright_yellow, :bright_blue, :bright_magenta, :bright_cyan, :bright_white,
|
635
|
+
:on_black, :on_red, :on_green, :on_yellow, :on_blue, :on_magenta, :on_cyan, :on_white,
|
636
|
+
:on_bright_black, :on_gray, :on_bright_red, :on_bright_green, :on_bright_yellow, :on_bright_blue, :on_bright_magenta, :on_bright_cyan, :on_bright_white
|
637
|
+
].each do |method_name|
|
638
|
+
describe ".#{method_name}" do
|
639
|
+
context "when given a string" do
|
640
|
+
it "must return that string" do
|
641
|
+
expect(subject.send(method_name,str)).to eq(str)
|
642
|
+
end
|
643
|
+
end
|
644
|
+
|
645
|
+
context "when given no arguments" do
|
646
|
+
it { expect(subject.send(method_name)).to eq('') }
|
647
|
+
end
|
617
648
|
end
|
618
649
|
end
|
619
650
|
end
|
@@ -625,6 +656,12 @@ describe CommandKit::Colors do
|
|
625
656
|
it { expect(subject.ansi?).to be(false) }
|
626
657
|
end
|
627
658
|
|
659
|
+
context "when NO_COLOR is set" do
|
660
|
+
subject { command_class.new(env: {'NO_COLOR' => 'true'}) }
|
661
|
+
|
662
|
+
it { expect(subject.ansi?).to be(false) }
|
663
|
+
end
|
664
|
+
|
628
665
|
context "when stdout is a TTY" do
|
629
666
|
let(:stdout) { StringIO.new }
|
630
667
|
subject { command_class.new(stdout: stdout) }
|
data/spec/command_name_spec.rb
CHANGED
data/spec/command_spec.rb
CHANGED
@@ -46,8 +46,8 @@ describe CommandKit::Command do
|
|
46
46
|
expect(described_class).to include(CommandKit::ExceptionHandler)
|
47
47
|
end
|
48
48
|
|
49
|
-
it "must include FileUtils" do
|
50
|
-
expect(described_class).to include(FileUtils)
|
49
|
+
it "must include CommandKit::FileUtils" do
|
50
|
+
expect(described_class).to include(CommandKit::FileUtils)
|
51
51
|
end
|
52
52
|
|
53
53
|
module TestCommandClass
|