tty-prompt 0.9.0 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +6 -4
- data/CHANGELOG.md +8 -0
- data/README.md +138 -137
- data/lib/tty/prompt.rb +5 -4
- data/lib/tty/prompt/test.rb +5 -2
- data/lib/tty/prompt/version.rb +1 -1
- data/spec/unit/say_spec.rb +10 -0
- data/tty-prompt.gemspec +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f4230c7c6fb6e3d32f7f52876da632d3fd0f053e
|
4
|
+
data.tar.gz: 9d2c67e6e967bb2340e3c7453d480ef95fa8108f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0b4fe2bd69c086b54f8da5ad56787860e868e196e8c647c4df2f260979018ac5e84a713ebfab9281864a824c25377a88864bfed7d53ec37e42c5869f0c0f42ca
|
7
|
+
data.tar.gz: 9964852cf8a42d9c6bf733ed77de1402190ee0c17de5b5f0b753e92d10c4429b9bf86be47d0ac1611b96217e3d797db9c7ab34cbe21288c4118a62ce323fe4de
|
data/.travis.yml
CHANGED
@@ -8,17 +8,19 @@ rvm:
|
|
8
8
|
- 1.9.3
|
9
9
|
- 2.0.0
|
10
10
|
- 2.1.10
|
11
|
-
- 2.2.
|
12
|
-
- 2.3.
|
11
|
+
- 2.2.6
|
12
|
+
- 2.3.3
|
13
|
+
- 2.4.0
|
13
14
|
- ruby-head
|
14
15
|
- jruby-9000
|
15
16
|
- jruby-head
|
16
|
-
- rbx-
|
17
|
+
- rbx-3
|
17
18
|
matrix:
|
18
19
|
allow_failures:
|
20
|
+
- rvm: 2.4.0
|
19
21
|
- rvm: ruby-head
|
20
22
|
- rvm: jruby-head
|
21
|
-
- rvm: rbx-
|
23
|
+
- rvm: rbx-3
|
22
24
|
fast_finish: true
|
23
25
|
branches:
|
24
26
|
only: master
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -47,36 +47,37 @@ Or install it yourself as:
|
|
47
47
|
* [1. Usage](#1-usage)
|
48
48
|
* [2. Interface](#2-interface)
|
49
49
|
* [2.1 ask](#21-ask)
|
50
|
-
|
51
|
-
* [2.2
|
52
|
-
* [2.
|
53
|
-
* [2.
|
54
|
-
* [2.
|
55
|
-
* [2.
|
56
|
-
* [2.
|
57
|
-
* [2.
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
* [2.
|
67
|
-
* [2.
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
* [2.
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
* [
|
50
|
+
* [2.1.1 convert](#211-convert)
|
51
|
+
* [2.1.2 default](#212-default)
|
52
|
+
* [2.1.3 echo](#213-echo)
|
53
|
+
* [2.1.4 error messages](#214-error-messages)
|
54
|
+
* [2.1.5 in](#215-in)
|
55
|
+
* [2.1.6 modify](#216-modify)
|
56
|
+
* [2.1.7 required](#217-required)
|
57
|
+
* [2.1.8 validate](#218-validate)
|
58
|
+
* [2.2 keypress](#22-keypress)
|
59
|
+
* [2.3 multiline](#23-multiline)
|
60
|
+
* [2.4 mask](#24-mask)
|
61
|
+
* [2.5 yes?/no?](#25-yesno)
|
62
|
+
* [2.6 menu](#26-menu)
|
63
|
+
* [2.6.1 select](#261-select)
|
64
|
+
* [2.6.2 multi_select](#262-multi_select)
|
65
|
+
* [2.6.3 enum_select](#263-enum_select)
|
66
|
+
* [2.7 expand](#27-expand)
|
67
|
+
* [2.8 collect](#28-collect)
|
68
|
+
* [2.9 suggest](#29-suggest)
|
69
|
+
* [2.10 slider](#210-slider)
|
70
|
+
* [2.11 say](#211-say)
|
71
|
+
* [2.11.1 ok](#2111-ok)
|
72
|
+
* [2.11.2 warn](#2112-warn)
|
73
|
+
* [2.11.3 error](#2113-error)
|
74
|
+
* [2.12 keyboard events](#212-keyboard-events)
|
75
|
+
* [3. settings](#3-settings)
|
76
|
+
* [3.1 active_color](#31-active_color)
|
77
|
+
* [3.2 enable_color](#32-enable-color)
|
78
|
+
* [3.3 help_color](#33-help_color)
|
79
|
+
* [3.4 interrupt](#34-interrupt)
|
80
|
+
* [3.5 prefix](#35-prefix)
|
80
81
|
|
81
82
|
## 1. Usage
|
82
83
|
|
@@ -200,23 +201,11 @@ prompt.ask("What is your name?") do |q|
|
|
200
201
|
end
|
201
202
|
```
|
202
203
|
|
203
|
-
|
204
|
+
#### 2.1.1 convert
|
204
205
|
|
205
|
-
|
206
|
+
The `convert` property is used to convert input to a required type.
|
206
207
|
|
207
|
-
|
208
|
-
:convert # conversion applied to input such as :bool or proc
|
209
|
-
:default # default value used if none is provided
|
210
|
-
:echo # turn echo on and off (default: true)
|
211
|
-
:in # specify range '0-9', '0..9', '0...9' or negative '-1..-9'
|
212
|
-
:modify # apply answer modification :upcase, :downcase, :trim, :chomp etc..
|
213
|
-
:required # If true, value entered must be non-empty (default: false)
|
214
|
-
:validate # regex, proc against which input is checked
|
215
|
-
```
|
216
|
-
|
217
|
-
#### 2.2.1 convert
|
218
|
-
|
219
|
-
The `convert` property is used to convert input to a required type. By default no conversion is performed. The following conversions are provided:
|
208
|
+
By default no conversion is performed. The following conversions are provided:
|
220
209
|
|
221
210
|
```ruby
|
222
211
|
:bool # true or false for strings such as "Yes", "No"
|
@@ -250,7 +239,7 @@ end
|
|
250
239
|
# => ['milk', 'eggs', 'flour']
|
251
240
|
```
|
252
241
|
|
253
|
-
#### 2.
|
242
|
+
#### 2.1.2 default
|
254
243
|
|
255
244
|
The `:default` option is used if the user presses return key:
|
256
245
|
|
@@ -260,7 +249,7 @@ prompt.ask('What is your name?', default: 'Anonymous')
|
|
260
249
|
# What is your name? (Anonymous)
|
261
250
|
```
|
262
251
|
|
263
|
-
#### 2.
|
252
|
+
#### 2.1.3 echo
|
264
253
|
|
265
254
|
To control whether the input is shown back in terminal or not use `:echo` option like so:
|
266
255
|
|
@@ -268,7 +257,37 @@ To control whether the input is shown back in terminal or not use `:echo` option
|
|
268
257
|
prompt.ask('password:', echo: false)
|
269
258
|
```
|
270
259
|
|
271
|
-
#### 2.
|
260
|
+
#### 2.1.4 error messages
|
261
|
+
|
262
|
+
By default `tty-prompt` comes with predefined error messages for `required`, `in`, `validate` options.
|
263
|
+
|
264
|
+
You can change these and configure to your liking either by inling them with the option:
|
265
|
+
|
266
|
+
```ruby
|
267
|
+
prompt.ask('What is your email?') do |q|
|
268
|
+
question.validate(/\A\w+@\w+\.\w+\Z/, 'Invalid email address')
|
269
|
+
end
|
270
|
+
```
|
271
|
+
|
272
|
+
or change the `messages` key entry out of `:required?`, `:valid?`, `:range?`:
|
273
|
+
|
274
|
+
```ruby
|
275
|
+
prompt.ask('What is your email?') do |q|
|
276
|
+
question.validate(/\A\w+@\w+\.\w+\Z/)
|
277
|
+
question.messages[:valid?] = 'Invalid email address'
|
278
|
+
end
|
279
|
+
```
|
280
|
+
|
281
|
+
to change default range validation error message do:
|
282
|
+
|
283
|
+
```ruby
|
284
|
+
prompt.ask('How spicy on scale (1-5)? ') do |q|
|
285
|
+
q.in '1-5'
|
286
|
+
q.messages[:range?] = '%{value} out of expected range #{in}'
|
287
|
+
end
|
288
|
+
```
|
289
|
+
|
290
|
+
#### 2.1.5 in
|
272
291
|
|
273
292
|
In order to check that provided input falls inside a range of inputs use the `in` option. For example, if we wanted to ask a user for a single digit in given range we may do following:
|
274
293
|
|
@@ -276,7 +295,7 @@ In order to check that provided input falls inside a range of inputs use the `in
|
|
276
295
|
ask("Provide number in range: 0-9?") { |q| q.in('0-9') }
|
277
296
|
```
|
278
297
|
|
279
|
-
#### 2.
|
298
|
+
#### 2.1.6 modify
|
280
299
|
|
281
300
|
Set the `:modify` option if you want to handle whitespace or letter capitalization.
|
282
301
|
|
@@ -301,7 +320,7 @@ Available whitespace settings are:
|
|
301
320
|
:remove # remove all whitespace
|
302
321
|
```
|
303
322
|
|
304
|
-
#### 2.
|
323
|
+
#### 2.1.7 required
|
305
324
|
|
306
325
|
To ensure that input is provided use `:required` option:
|
307
326
|
|
@@ -311,7 +330,7 @@ prompt.ask("What's your phone number?", required: true)
|
|
311
330
|
# >> Value must be provided
|
312
331
|
```
|
313
332
|
|
314
|
-
#### 2.
|
333
|
+
#### 2.1.8 validate
|
315
334
|
|
316
335
|
In order to validate that input matches a given patter you can pass the `validate` option. Validate setting accepts `Regex`, `Proc` or `Symbol`.
|
317
336
|
|
@@ -327,76 +346,7 @@ The **TTY::Prompt** comes with bult-in validations for `:email` and you can use
|
|
327
346
|
prompt.ask('What is your email?') { |q| q.validate :email }
|
328
347
|
```
|
329
348
|
|
330
|
-
|
331
|
-
|
332
|
-
By default `tty-prompt` comes with predefined error messages for `required`, `in`, `validate` options. You can change these and configure to your liking either by inling them with the option:
|
333
|
-
|
334
|
-
```ruby
|
335
|
-
prompt.ask('What is your email?') do |q|
|
336
|
-
question.validate(/\A\w+@\w+\.\w+\Z/, 'Invalid email address')
|
337
|
-
end
|
338
|
-
```
|
339
|
-
|
340
|
-
or change the `messages` key entry out of `:required?`, `:valid?`, `:range?`:
|
341
|
-
|
342
|
-
```ruby
|
343
|
-
prompt.ask('What is your email?') do |q|
|
344
|
-
question.validate(/\A\w+@\w+\.\w+\Z/)
|
345
|
-
question.messages[:valid?] = 'Invalid email address'
|
346
|
-
end
|
347
|
-
```
|
348
|
-
|
349
|
-
to change default range validation error message do:
|
350
|
-
|
351
|
-
```ruby
|
352
|
-
prompt.ask('How spicy on scale (1-5)? ') do |q|
|
353
|
-
q.in '1-5'
|
354
|
-
q.messages[:range?] = '%{value} out of expected range #{in}'
|
355
|
-
end
|
356
|
-
```
|
357
|
-
|
358
|
-
#### 2.2.9 prefix
|
359
|
-
|
360
|
-
You can prefix each question asked using the `:prefix` option. This option can be applied either globally for all prompts or individual for each one:
|
361
|
-
|
362
|
-
```ruby
|
363
|
-
prompt = TTY::Prompt.new(prefix: '[?] ')
|
364
|
-
```
|
365
|
-
|
366
|
-
#### 2.2.10 active_color
|
367
|
-
|
368
|
-
All prompt types support `:active_color` option. In case of `select`, `multi_select`, `enum_select` or `expand` this color is used to highlight the currently selected choice. All the resulted inputs provided by user that are read in by the prompt as answer are highlighted with this color. This option can be applied either globablly for all prompts or individually.
|
369
|
-
|
370
|
-
```ruby
|
371
|
-
prompt.select('What size?', %w(Large Medium Small), active_color: :cyan)
|
372
|
-
```
|
373
|
-
|
374
|
-
Please [see pastel](https://github.com/piotrmurach/pastel#3-supported-colors) for all supported colors.
|
375
|
-
|
376
|
-
#### 2.2.11 help_color
|
377
|
-
|
378
|
-
Prompts such as `select`, `multi_select`, `expand` support `:help_color` which is used to customize the help text. This option can be applied either globablly for all prompts or individually.
|
379
|
-
|
380
|
-
```ruby
|
381
|
-
prompt.select('What size?', %w(Large Medium Small), help_color: :cyan)
|
382
|
-
```
|
383
|
-
|
384
|
-
#### 2.2.12 interrupt
|
385
|
-
|
386
|
-
By default `InputInterrupt` error will be raised when the user hits the interrupt key(Control-C). However, you can customise this behaviour by passing the `:interrupt` option. The available options are:
|
387
|
-
|
388
|
-
* `:signal` - sends interrupt signal
|
389
|
-
* `:exit` - exists with status code
|
390
|
-
* `:noop` - skips handler
|
391
|
-
* custom proc
|
392
|
-
|
393
|
-
For example, to send interrupt signal do:
|
394
|
-
|
395
|
-
```ruby
|
396
|
-
prompt = TTY::Prompt.new(interrupt: :signal)
|
397
|
-
```
|
398
|
-
|
399
|
-
### 2.3 keypress
|
349
|
+
### 2.2. keypress
|
400
350
|
|
401
351
|
In order to ask question with a single character or keypress answer use `keypress`:
|
402
352
|
|
@@ -404,7 +354,7 @@ In order to ask question with a single character or keypress answer use `keypres
|
|
404
354
|
prompt.keypress("Which one do you prefer a, b, c or d ?")
|
405
355
|
```
|
406
356
|
|
407
|
-
### 2.
|
357
|
+
### 2.3 multiline
|
408
358
|
|
409
359
|
Asking for multiline input can be done with `multiline` method.
|
410
360
|
|
@@ -414,7 +364,7 @@ prompt.multiline("Provide description?")
|
|
414
364
|
|
415
365
|
The reading of input will terminate when empty line is submitted.
|
416
366
|
|
417
|
-
### 2.
|
367
|
+
### 2.4 mask
|
418
368
|
|
419
369
|
If you require input of confidential information use `mask` method. By default each character that is printed is replaced by `•` symbol. All configuration options applicable to `ask` method can be used with `mask` as well.
|
420
370
|
|
@@ -436,7 +386,7 @@ If you don't wish to show any output use `:echo` option like so:
|
|
436
386
|
prompt.mask('What is your secret?', echo: false)
|
437
387
|
```
|
438
388
|
|
439
|
-
### 2.
|
389
|
+
### 2.5 yes?/no?
|
440
390
|
|
441
391
|
In order to display a query asking for boolean input from user use `yes?` like so:
|
442
392
|
|
@@ -493,9 +443,9 @@ prompt.no?('Do you hate Ruby?')
|
|
493
443
|
|
494
444
|
Similarly to `yes?` method, you can supply the same options to customize the question.
|
495
445
|
|
496
|
-
### 2.
|
446
|
+
### 2.6 menu
|
497
447
|
|
498
|
-
### 2.
|
448
|
+
### 2.6.1 select
|
499
449
|
|
500
450
|
For asking questions involving list of options use `select` method by passing the question and possible choices:
|
501
451
|
|
@@ -615,7 +565,7 @@ prompt.select("Choose your letter?") do |menu|
|
|
615
565
|
end
|
616
566
|
```
|
617
567
|
|
618
|
-
### 2.
|
568
|
+
### 2.6.2 multi_select
|
619
569
|
|
620
570
|
For asking questions involving multiple selection list use `multi_select` method by passing the question and possible choices:
|
621
571
|
|
@@ -730,7 +680,7 @@ prompt.multi_select("Choose your letter?", letters, per_page: 4)
|
|
730
680
|
# (Move up or down to reveal more choices)
|
731
681
|
```
|
732
682
|
|
733
|
-
### 2.
|
683
|
+
### 2.6.3 enum_select
|
734
684
|
|
735
685
|
In order to ask for standard selection from indexed list you can use `enum_select` and pass question together with possible choices:
|
736
686
|
|
@@ -804,7 +754,7 @@ prompt.enum_select("Choose your letter?", letters, per_page: 4)
|
|
804
754
|
# (Press tab/right or left to reveal more choices)
|
805
755
|
```
|
806
756
|
|
807
|
-
### 2.
|
757
|
+
### 2.7 expand
|
808
758
|
|
809
759
|
The `expand` provides a compact way to ask a question with many options.
|
810
760
|
|
@@ -868,7 +818,7 @@ If user types `h` and presses enter, an expanded view will be shown which furthe
|
|
868
818
|
|
869
819
|
Run `examples/expand.rb` to see the prompt in action.
|
870
820
|
|
871
|
-
### 2.
|
821
|
+
### 2.8 collect
|
872
822
|
|
873
823
|
In order to collect more than one answer use `collect` method. Using the `key` you can describe the answers key name. All the methods for asking user input such as `ask`, `mask`, `select` can be directly invoked on the key. The key composition is very flexible by allowing nested keys. If you want the value to be automatically converted to required type use [convert](#221-convert).
|
874
824
|
|
@@ -890,7 +840,7 @@ end
|
|
890
840
|
# {:name => "Piotr", :age => 30, :address => {:street => "Street", :city => "City", :zip => "123"}}
|
891
841
|
```
|
892
842
|
|
893
|
-
### 2.
|
843
|
+
### 2.9 suggest
|
894
844
|
|
895
845
|
To suggest possible matches for the user input use `suggest` method like so:
|
896
846
|
|
@@ -912,7 +862,7 @@ prompt.suggest('b', possible, indent: 4, single_text: 'Perhaps you meant?')
|
|
912
862
|
# blame
|
913
863
|
```
|
914
864
|
|
915
|
-
### 2.
|
865
|
+
### 2.10 slider
|
916
866
|
|
917
867
|
If you have constrained range of numbers for user to choose from you may consider using `slider`. The slider provides easy visual way of picking a value marked by `O` marker.
|
918
868
|
|
@@ -939,7 +889,7 @@ end
|
|
939
889
|
# |--O-------| 4
|
940
890
|
```
|
941
891
|
|
942
|
-
### 2.
|
892
|
+
### 2.11 say
|
943
893
|
|
944
894
|
To simply print message out to stdout use `say` like so:
|
945
895
|
|
@@ -951,7 +901,7 @@ The `say` method also accepts option `:color` which supports all the colors prov
|
|
951
901
|
|
952
902
|
**TTY::Prompt** provides more specific versions of `say` method to better express intenation behind the message such as `ok`, `warn` and `error`.
|
953
903
|
|
954
|
-
#### 2.
|
904
|
+
#### 2.11.1 ok
|
955
905
|
|
956
906
|
Print message(s) in green do:
|
957
907
|
|
@@ -967,7 +917,7 @@ Print message(s) in yellow do:
|
|
967
917
|
prompt.warn(...)
|
968
918
|
```
|
969
919
|
|
970
|
-
#### 2.
|
920
|
+
#### 2.11.3 error
|
971
921
|
|
972
922
|
Print message(s) in red do:
|
973
923
|
|
@@ -975,7 +925,7 @@ Print message(s) in red do:
|
|
975
925
|
prompt.error(...)
|
976
926
|
```
|
977
927
|
|
978
|
-
#### 2.
|
928
|
+
#### 2.12 keyboard events
|
979
929
|
|
980
930
|
All the prompt types, when a key is pressed, fire key press events. You can subscribe to listen to this events by calling `on` with type of event name.
|
981
931
|
|
@@ -1027,6 +977,57 @@ The available events are:
|
|
1027
977
|
* `:keydelete`
|
1028
978
|
* `:keybackspace`
|
1029
979
|
|
980
|
+
## 3 settings
|
981
|
+
|
982
|
+
### 3.1 active_color
|
983
|
+
|
984
|
+
All prompt types support `:active_color` option. In case of `select`, `multi_select`, `enum_select` or `expand` this color is used to highlight the currently selected choice. All the resulted inputs provided by user that are read in by the prompt as answer are highlighted with this color. This option can be applied either globablly for all prompts or individually.
|
985
|
+
|
986
|
+
```ruby
|
987
|
+
prompt.select('What size?', %w(Large Medium Small), active_color: :cyan)
|
988
|
+
```
|
989
|
+
|
990
|
+
Please [see pastel](https://github.com/piotrmurach/pastel#3-supported-colors) for all supported colors.
|
991
|
+
|
992
|
+
### 3.2 enable_color
|
993
|
+
|
994
|
+
If you wish to disable coloring for a prompt simply pass `:enable_color` option
|
995
|
+
|
996
|
+
```
|
997
|
+
prompt = TTY::Prompt.new(enable_color: true)
|
998
|
+
```
|
999
|
+
|
1000
|
+
### 3.3 help_color
|
1001
|
+
|
1002
|
+
Prompts such as `select`, `multi_select`, `expand` support `:help_color` which is used to customize the help text. This option can be applied either globablly for all prompts or individually.
|
1003
|
+
|
1004
|
+
```ruby
|
1005
|
+
prompt.select('What size?', %w(Large Medium Small), help_color: :cyan)
|
1006
|
+
```
|
1007
|
+
|
1008
|
+
### 3.4 interrupt
|
1009
|
+
|
1010
|
+
By default `InputInterrupt` error will be raised when the user hits the interrupt key(Control-C). However, you can customise this behaviour by passing the `:interrupt` option. The available options are:
|
1011
|
+
|
1012
|
+
* `:signal` - sends interrupt signal
|
1013
|
+
* `:exit` - exists with status code
|
1014
|
+
* `:noop` - skips handler
|
1015
|
+
* custom proc
|
1016
|
+
|
1017
|
+
For example, to send interrupt signal do:
|
1018
|
+
|
1019
|
+
```ruby
|
1020
|
+
prompt = TTY::Prompt.new(interrupt: :signal)
|
1021
|
+
```
|
1022
|
+
|
1023
|
+
### 3.5 prefix
|
1024
|
+
|
1025
|
+
You can prefix each question asked using the `:prefix` option. This option can be applied either globally for all prompts or individual for each one:
|
1026
|
+
|
1027
|
+
```ruby
|
1028
|
+
prompt = TTY::Prompt.new(prefix: '[?] ')
|
1029
|
+
```
|
1030
|
+
|
1030
1031
|
## Contributing
|
1031
1032
|
|
1032
1033
|
1. Fork it ( https://github.com/piotrmurach/tty-prompt/fork )
|
@@ -1039,4 +1040,4 @@ This project is intended to be a safe, welcoming space for collaboration, and co
|
|
1039
1040
|
|
1040
1041
|
## Copyright
|
1041
1042
|
|
1042
|
-
Copyright (c) 2015-
|
1043
|
+
Copyright (c) 2015-2017 Piotr Murach. See LICENSE for further details.
|
data/lib/tty/prompt.rb
CHANGED
@@ -70,12 +70,13 @@ module TTY
|
|
70
70
|
@input = options.fetch(:input) { $stdin }
|
71
71
|
@output = options.fetch(:output) { $stdout }
|
72
72
|
@prefix = options.fetch(:prefix) { '' }
|
73
|
-
@
|
74
|
-
@
|
75
|
-
@
|
73
|
+
@enabled_color = options[:enable_color]
|
74
|
+
@active_color = options.fetch(:active_color) { :green }
|
75
|
+
@help_color = options.fetch(:help_color) { :bright_black }
|
76
|
+
@error_color = options.fetch(:error_color) { :red }
|
76
77
|
|
77
78
|
@cursor = TTY::Cursor
|
78
|
-
@pastel = Pastel.new
|
79
|
+
@pastel = Pastel.new(@enabled_color.nil? ? {} : { enabled: @enabled_color })
|
79
80
|
@reader = Reader.new(@input, @output, interrupt: options[:interrupt])
|
80
81
|
end
|
81
82
|
|
data/lib/tty/prompt/test.rb
CHANGED
@@ -8,9 +8,12 @@ module TTY
|
|
8
8
|
def initialize(options = {})
|
9
9
|
@input = StringIO.new
|
10
10
|
@output = StringIO.new
|
11
|
-
options.merge!({
|
11
|
+
options.merge!({
|
12
|
+
input: @input,
|
13
|
+
output: @output,
|
14
|
+
enable_color: options.fetch(:enable_color) { true }
|
15
|
+
})
|
12
16
|
super(options)
|
13
|
-
@pastel = Pastel.new(enabled: true)
|
14
17
|
end
|
15
18
|
end # TestPrompt
|
16
19
|
end # TTY
|
data/lib/tty/prompt/version.rb
CHANGED
data/spec/unit/say_spec.rb
CHANGED
@@ -54,4 +54,14 @@ RSpec.describe TTY::Prompt, '#say' do
|
|
54
54
|
expect(prompt.output.string).to eq("\e[32mHell yeah! \e[0m")
|
55
55
|
end
|
56
56
|
end
|
57
|
+
|
58
|
+
context 'without color' do
|
59
|
+
it 'prints message without ansi' do
|
60
|
+
prompt = TTY::TestPrompt.new(enable_color: false)
|
61
|
+
|
62
|
+
prompt.say('Hell yeah!', color: :green)
|
63
|
+
|
64
|
+
expect(prompt.output.string).to eq("Hell yeah!\n")
|
65
|
+
end
|
66
|
+
end
|
57
67
|
end
|
data/tty-prompt.gemspec
CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
21
|
spec.add_dependency 'necromancer', '~> 0.3.0'
|
22
|
-
spec.add_dependency 'pastel', '~> 0.
|
22
|
+
spec.add_dependency 'pastel', '~> 0.7.0'
|
23
23
|
spec.add_dependency 'tty-cursor', '~> 0.3.0'
|
24
24
|
spec.add_dependency 'wisper', '~> 1.6.1'
|
25
25
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tty-prompt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Piotr Murach
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-01-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: necromancer
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.
|
33
|
+
version: 0.7.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.
|
40
|
+
version: 0.7.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: tty-cursor
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|