tty-prompt 0.2.0 → 0.3.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.
Files changed (108) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +9 -6
  3. data/CHANGELOG.md +40 -3
  4. data/Gemfile +0 -1
  5. data/README.md +246 -65
  6. data/examples/ask.rb +7 -0
  7. data/examples/echo.rb +7 -0
  8. data/examples/in.rb +7 -0
  9. data/examples/mask.rb +9 -0
  10. data/examples/multi_select.rb +8 -0
  11. data/examples/select.rb +8 -0
  12. data/examples/validation.rb +9 -0
  13. data/examples/yes_no.rb +7 -0
  14. data/lib/tty-prompt.rb +6 -4
  15. data/lib/tty/prompt.rb +100 -25
  16. data/lib/tty/prompt/choice.rb +1 -1
  17. data/lib/tty/prompt/converter_dsl.rb +19 -0
  18. data/lib/tty/prompt/converter_registry.rb +56 -0
  19. data/lib/tty/prompt/converters.rb +77 -0
  20. data/lib/tty/prompt/evaluator.rb +29 -0
  21. data/lib/tty/prompt/list.rb +38 -36
  22. data/lib/tty/prompt/mask_question.rb +85 -0
  23. data/lib/tty/prompt/multi_list.rb +21 -32
  24. data/lib/tty/prompt/question.rb +184 -162
  25. data/lib/tty/prompt/question/checks.rb +85 -0
  26. data/lib/tty/prompt/question/modifier.rb +4 -5
  27. data/lib/tty/prompt/question/validation.rb +29 -35
  28. data/lib/tty/prompt/reader.rb +98 -52
  29. data/lib/tty/prompt/reader/codes.rb +63 -0
  30. data/lib/tty/prompt/reader/key_event.rb +67 -0
  31. data/lib/tty/prompt/reader/mode.rb +66 -0
  32. data/lib/tty/prompt/reader/mode/echo.rb +43 -0
  33. data/lib/tty/prompt/reader/mode/raw.rb +43 -0
  34. data/lib/tty/prompt/result.rb +42 -0
  35. data/lib/tty/prompt/statement.rb +9 -14
  36. data/lib/tty/prompt/suggestion.rb +4 -2
  37. data/lib/tty/prompt/symbols.rb +13 -0
  38. data/lib/tty/prompt/test.rb +3 -2
  39. data/lib/tty/prompt/utils.rb +1 -1
  40. data/lib/tty/prompt/version.rb +1 -1
  41. data/spec/unit/ask_spec.rb +31 -48
  42. data/spec/unit/choice/eql_spec.rb +0 -2
  43. data/spec/unit/choice/from_spec.rb +0 -2
  44. data/spec/unit/choices/add_spec.rb +0 -2
  45. data/spec/unit/choices/each_spec.rb +0 -2
  46. data/spec/unit/choices/new_spec.rb +0 -2
  47. data/spec/unit/choices/pluck_spec.rb +0 -2
  48. data/spec/unit/converters/convert_bool_spec.rb +58 -0
  49. data/spec/unit/{response/read_char_spec.rb → converters/convert_char_spec.rb} +2 -4
  50. data/spec/unit/converters/convert_custom_spec.rb +14 -0
  51. data/spec/unit/converters/convert_date_spec.rb +25 -0
  52. data/spec/unit/converters/convert_file_spec.rb +14 -0
  53. data/spec/unit/{response/read_number_spec.rb → converters/convert_number_spec.rb} +5 -7
  54. data/spec/unit/converters/convert_path_spec.rb +15 -0
  55. data/spec/unit/{response/read_range_spec.rb → converters/convert_range_spec.rb} +3 -5
  56. data/spec/unit/converters/convert_regex_spec.rb +12 -0
  57. data/spec/unit/converters/convert_string_spec.rb +21 -0
  58. data/spec/unit/distance/distance_spec.rb +0 -2
  59. data/spec/unit/error_spec.rb +0 -6
  60. data/spec/unit/evaluator_spec.rb +67 -0
  61. data/spec/unit/keypress_spec.rb +19 -0
  62. data/spec/unit/mask_spec.rb +95 -0
  63. data/spec/unit/multi_select_spec.rb +36 -24
  64. data/spec/unit/multiline_spec.rb +19 -0
  65. data/spec/unit/new_spec.rb +18 -0
  66. data/spec/unit/ok_spec.rb +10 -0
  67. data/spec/unit/question/default_spec.rb +17 -4
  68. data/spec/unit/question/echo_spec.rb +31 -0
  69. data/spec/unit/question/in_spec.rb +48 -16
  70. data/spec/unit/question/initialize_spec.rb +2 -9
  71. data/spec/unit/question/modifier/apply_to_spec.rb +9 -16
  72. data/spec/unit/question/modifier/letter_case_spec.rb +0 -2
  73. data/spec/unit/question/modifier/whitespace_spec.rb +12 -20
  74. data/spec/unit/question/modify_spec.rb +3 -7
  75. data/spec/unit/question/required_spec.rb +20 -14
  76. data/spec/unit/question/validate_spec.rb +20 -19
  77. data/spec/unit/question/validation/call_spec.rb +15 -6
  78. data/spec/unit/question/validation/coerce_spec.rb +17 -11
  79. data/spec/unit/reader/publish_keypress_event_spec.rb +81 -0
  80. data/spec/unit/reader/read_keypress_spec.rb +22 -0
  81. data/spec/unit/reader/read_line_spec.rb +31 -0
  82. data/spec/unit/reader/read_multiline_spec.rb +37 -0
  83. data/spec/unit/result_spec.rb +40 -0
  84. data/spec/unit/say_spec.rb +18 -23
  85. data/spec/unit/select_spec.rb +37 -32
  86. data/spec/unit/statement/initialize_spec.rb +4 -4
  87. data/spec/unit/suggest_spec.rb +0 -2
  88. data/spec/unit/warn_spec.rb +0 -5
  89. data/spec/unit/yes_no_spec.rb +70 -0
  90. data/tty-prompt.gemspec +7 -4
  91. metadata +123 -40
  92. data/lib/tty/prompt/codes.rb +0 -32
  93. data/lib/tty/prompt/cursor.rb +0 -131
  94. data/lib/tty/prompt/error.rb +0 -26
  95. data/lib/tty/prompt/mode.rb +0 -64
  96. data/lib/tty/prompt/mode/echo.rb +0 -41
  97. data/lib/tty/prompt/mode/raw.rb +0 -41
  98. data/lib/tty/prompt/response.rb +0 -247
  99. data/lib/tty/prompt/response_delegation.rb +0 -42
  100. data/spec/unit/cursor/new_spec.rb +0 -74
  101. data/spec/unit/question/character_spec.rb +0 -13
  102. data/spec/unit/reader/getc_spec.rb +0 -42
  103. data/spec/unit/response/read_bool_spec.rb +0 -58
  104. data/spec/unit/response/read_date_spec.rb +0 -16
  105. data/spec/unit/response/read_email_spec.rb +0 -45
  106. data/spec/unit/response/read_multiple_spec.rb +0 -21
  107. data/spec/unit/response/read_spec.rb +0 -69
  108. data/spec/unit/response/read_string_spec.rb +0 -14
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5e24965d09c08a3bf136438bad66551d05f25a0f
4
- data.tar.gz: 476702a67dd13fe4796c888d089107f4b6f7f18d
3
+ metadata.gz: a6c43cfd17fb7fe5d5f256f124571fb904a3d6b3
4
+ data.tar.gz: 0cc290a7c31157fe9d953133ce2f7a3df5042142
5
5
  SHA512:
6
- metadata.gz: 0645bb40ca7b847976e69d0d3c65e4e0a9441f4e3bade6ef1e0d38e7d9ef28e66132645aa30740c7a258939fe262664ed93306968eb76969bee768029d19c406
7
- data.tar.gz: 70c03c2eb72010d0efe7d8a125c285dc32ec34117e29e2a44b17839c645a8b1650dd14d1184b7b8a871dc92b2c44121ab1e727aa9f5ca41c893184b678171fc8
6
+ metadata.gz: b20f2aa8fab1798c62b8e5a9770351ab58fcf6de0afbbf7a60eba88c31e0b551273cd706944a3e17e3b6e1f6f1366d5e0d60f8c61b638c28dc6e9f0b657b9aac
7
+ data.tar.gz: 6f2be862205c779ba31d2651b4e9d7874d5df4a4566218e0793224215db197900dc930022940418f04fb7427948036928897e7384f65570f5d741f05b7f405e8
data/.travis.yml CHANGED
@@ -1,4 +1,7 @@
1
+ ---
1
2
  language: ruby
3
+ sudo: false
4
+ cache: bundler
2
5
  bundler_args: --without yard benchmarks
3
6
  script: "bundle exec rake ci"
4
7
  rvm:
@@ -7,13 +10,13 @@ rvm:
7
10
  - 2.1
8
11
  - 2.2
9
12
  - ruby-head
13
+ - jruby-19mode
14
+ - jruby
15
+ - rbx-2
16
+ env:
17
+ global:
18
+ - JRUBY_OPTS="-Xcli.debug=true --debug"
10
19
  matrix:
11
- include:
12
- - rvm: jruby-19mode
13
- - rvm: jruby-20mode
14
- - rvm: jruby-21mode
15
- - rvm: jruby-head
16
- - rvm: rbx-2
17
20
  allow_failures:
18
21
  - rvm: ruby-head
19
22
  - rvm: jruby-head
data/CHANGELOG.md CHANGED
@@ -1,12 +1,49 @@
1
- 0.2.0 (Nov 23, 2015)
1
+ # Change log
2
2
 
3
+ ## [v0.3.0] - 2015-12-28
4
+
5
+ ### Added
6
+ * Add prefix option to prompt to customize #ask, #select, #multi_select
7
+ * Add default printing to #ask
8
+ * Add #yes?/#no? boolean queries
9
+ * Add Evaluator and Result for validation checking to Question
10
+ * Add ability for #ask to display error messages on failed validation
11
+ * Add ability to specify in-built names for validation e.i. :email
12
+ * Add KeyEvent for keyboard events publishing to Reader
13
+ * Add #read_multiline to Reader
14
+ * Add :convert option for ask configuration
15
+ * Add ability to specify custom proc converters
16
+ * Add #ask_keypress to gather character input
17
+ * Add #ask_multiline to gather multiline input
18
+ * Add MaskedQuestion & #mask method for masking input stream characters
19
+
20
+ ### Changed
21
+ * Change Reader#read_keypress to be robust and read correctly byte sequences
22
+ * Change Reader#getc to #read_line and extend arguments with echo option
23
+ * Extract cursor movement to dependency tty-cursor
24
+ * Change List & MultiList to subscribe to keyboard events
25
+ * Change to move mode inside reader namespace
26
+ * Remove Response & Error objects
27
+ * Remove :char option from #ask
28
+ * Change :read option to specify mode of reading out of :line, :multiline, :keypress
29
+ * Rename #confirm to #ok
30
+
31
+ ## [v0.2.0] - 2015-11-23
32
+
33
+ ### Added
3
34
  * Add ability to select choice form list #select
4
35
  * Add ability to select multiple options #multi_select
36
+ * Add :read option to #ask for reading specific type input
37
+
38
+ ### Changed
5
39
  * Change #ask api to be similar to #select and #multi_select behaviour
6
40
  * Change #ask :argument option to be :required
7
- * Add :read option to #ask for reading specific type input
8
41
  * Remove :valid option from #ask as #select is a better solution
9
42
 
10
- 0.1.0 (Nov 1, 2015)
43
+ ## [v0.1.0] - 2015-11-01
11
44
 
12
45
  * Initial implementation and release
46
+
47
+ [v0.3.0]: https://github.com/peter-murach/tty-prompt/compare/v0.2.0...v0.3.0
48
+ [v0.2.0]: https://github.com/peter-murach/tty-prompt/compare/v0.1.0...v0.2.0
49
+ [v0.1.0]: https://github.com/peter-murach/tty-prompt/compare/v0.1.0
data/Gemfile CHANGED
@@ -3,7 +3,6 @@ source 'https://rubygems.org'
3
3
  gemspec
4
4
 
5
5
  group :development do
6
- gem 'rake', '~> 10.4.2'
7
6
  gem 'rspec', '~> 3.3.0'
8
7
  gem 'yard', '~> 0.8.7'
9
8
  gem 'benchmark-ips', '~> 2.0.0'
data/README.md CHANGED
@@ -41,12 +41,25 @@ Or install it yourself as:
41
41
  * [1. Usage](#1-usage)
42
42
  * [2. Interface](#2-interface)
43
43
  * [2.1 ask](#21-ask)
44
- * [2.1.1 settings](#211-settings)
45
- * [2.1.2 valid read keywords](#212-valid-read-keywords)
46
- * [2.2 select](#22-select)
47
- * [2.3 multi_select](#23-multi_select)
48
- * [2.4 say](#25-say)
49
- * [2.5 suggest](#26-suggest)
44
+ * [2.2 settings](#22-settings)
45
+ * [2.2.1 convert](#221-convert)
46
+ * [2.2.2 default](#222-default)
47
+ * [2.2.3 echo](#223-echo)
48
+ * [2.2.4 in](#224-in)
49
+ * [2.2.5 modify](#225-modify)
50
+ * [2.2.6 required](#226-required)
51
+ * [2.2.7 validate](#227-validate)
52
+ * [2.3 keypress](#23-keypress)
53
+ * [2.4 multiline](#24-multiline)
54
+ * [2.5 mask](#25-mask)
55
+ * [2.6 yes?/no?](#26-yesno)
56
+ * [2.7 select](#27-select)
57
+ * [2.8 multi_select](#28-multi_select)
58
+ * [2.9 suggest](#29-suggest)
59
+ * [2.10 say](#210-say)
60
+ * [2.11 ok](#211-ok)
61
+ * [2.12 warn](#212-warn)
62
+ * [2.13 error](#213-warn)
50
63
 
51
64
  ## 1. Usage
52
65
 
@@ -59,7 +72,22 @@ prompt = TTY::Prompt.new
59
72
  and then call `ask` with the question for simple input:
60
73
 
61
74
  ```ruby
62
- prompt.ask('Do you like Ruby?', type: :bool) # => true
75
+ prompt.ask('What is your name?', default: ENV['USER'])
76
+ # => What is your name? (piotr)
77
+ ```
78
+
79
+ To confirm input use `yes?`:
80
+
81
+ ```ruby
82
+ prompt.yes?('Do you like Ruby?')
83
+ # => Do you like Ruby? (Y/n)
84
+ ```
85
+
86
+ If you want to input password or secret information use `mask`:
87
+
88
+ ```ruby
89
+ prompt.mask("What is your secret?")
90
+ # => What is your secret? ••••
63
91
  ```
64
92
 
65
93
  Asking question with list of options couldn't be easier using `select` like so:
@@ -92,13 +120,13 @@ prompt.select("Select drinks?", choices)
92
120
 
93
121
  ### 2.1 ask
94
122
 
95
- In order to ask a basic question with a string answer do:
123
+ In order to ask a basic question do:
96
124
 
97
125
  ```ruby
98
- answer = prompt.ask("What is your name?")
126
+ prompt.ask("What is your name?")
99
127
  ```
100
128
 
101
- In order to prompt for more complex input you can use robust API by passing hash of properties or using block:
129
+ However, to prompt for more complex input you can use robust API by passing hash of properties or using a block like so:
102
130
 
103
131
  ```ruby
104
132
  prompt.ask("What is your name?") do |q|
@@ -108,66 +136,199 @@ prompt.ask("What is your name?") do |q|
108
136
  end
109
137
  ```
110
138
 
111
- #### 2.1.1 settings
139
+ ### 2.2 settings
112
140
 
113
- Below is a list of the settings that may be used for customizing `ask` method behaviour:
141
+ Below is a list of the settings that may be used for customizing `ask`, `mask`, `multiline`, `keypress` methods behaviour:
114
142
 
115
143
  ```ruby
116
- char # turn character based input, otherwise line (default: false)
117
- default # default value used if none is provided
118
- echo # turn echo on and off (default: true)
119
- in # specify range '0-9', '0..9', '0...9' or negative '-1..-9'
120
- mask # mask characters i.e '****' (default: false)
121
- modify # apply answer modification :upcase, :downcase, :trim, :chomp etc..
122
- read # Specifies the type of input such as :bool, :string [see](#211-valid-read-keywords)
123
- required # If true, value entered must be non-empty (default: false)
124
- validate # regex, proc against which stdin input is checked
144
+ :convert # conversion applied to input such as :bool or proc
145
+ :default # default value used if none is provided
146
+ :echo # turn echo on and off (default: true)
147
+ :in # specify range '0-9', '0..9', '0...9' or negative '-1..-9'
148
+ :modify # apply answer modification :upcase, :downcase, :trim, :chomp etc..
149
+ :required # If true, value entered must be non-empty (default: false)
150
+ :validate # regex, proc against which input is checked
125
151
  ```
126
152
 
127
- Validate setting can take `Regex`, `Proc` like so:
153
+ #### 2.2.1 convert
128
154
 
129
- ```ruby
130
- prompt.ask('What is your username?') { |q|
131
- q.validate { |input| input =~ (/^[^\.]+\.[^\.]+/) }
132
- }
133
- ```
134
-
135
- For example, if we wanted to ask a user for a single digit in given range
136
-
137
- ```ruby
138
- ask("Provide number in range: 0-9") { |q| q.in('0-9') }
139
- ```
140
-
141
- #### 2.1.2 valid read keywords
142
-
143
- The most common thing to do is to cast the answer to specific type. The `read` property is used for that. By default `:string` answer is assumed but this can be changed using one of the following custom readers:
155
+ The `convert` property is used to convert input to a required type. By default no conversion is performed. The following conversions are provided:
144
156
 
145
157
  ```ruby
146
158
  :bool # true or false for strings such as "Yes", "No"
147
- :char # first character
148
159
  :date # date type
149
160
  :datetime # datetime type
150
- :email # validate answer against email regex
151
- :file # a File object
161
+ :file # File object
152
162
  :float # decimal or error if cannot convert
153
163
  :int # integer or error if cannot convert
154
- :multiline # multiple line string
155
- :password # string with echo turned off
164
+ :path # Pathname object
156
165
  :range # range type
157
- :regex # regex expression
166
+ :regexp # regex expression
158
167
  :string # string
159
168
  :symbol # symbol
160
- :text # multiline string
161
- :keypress # the key pressed
162
169
  ```
163
170
 
164
171
  For example, if you are interested in range type as answer do the following:
165
172
 
166
173
  ```ruby
167
- ask("Provide range of numbers?", read: :range)
174
+ prompt.ask("Provide range of numbers?", convert: :range)
175
+ # Provide range of numbers? 1-10
176
+ # => 1..10
177
+ ```
178
+
179
+ You can also provide a custom conversion like so:
180
+
181
+ ```ruby
182
+ prompt.ask('Ingredients? (comma sep list)') do |q|
183
+ q.convert -> (input) { input.split(/,\s*/) }
184
+ end
185
+ # Ingredients? (comma sep list) milk, eggs, flour
186
+ # => ['milk', 'eggs', 'flour']
187
+ ```
188
+
189
+ #### 2.2.2 default
190
+
191
+ The `:default` option is used if the user presses return key:
192
+
193
+ ```ruby
194
+ prompt.ask('What is your name?', default: 'Anonymous')
195
+ # =>
196
+ # What is your name? (Anonymous)
197
+ ```
198
+
199
+ #### 2.2.3 echo
200
+
201
+ To control whether the input is shown back in terminal or not use `:echo` option like so:
202
+
203
+ ```ruby
204
+ prompt.ask('password:', echo: false)
205
+ ```
206
+
207
+ #### 2.2.4 in
208
+
209
+ 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:
210
+
211
+ ```ruby
212
+ ask("Provide number in range: 0-9?") { |q| q.in('0-9') }
213
+ ```
214
+
215
+ #### 2.2.5 modify
216
+
217
+ Set the `:modify` option if you want to handle whitespace or letter capitalization.
218
+
219
+ ```ruby
220
+ prompt.ask('Enter text:') do |q|
221
+ q.modify :strip, :collapse
222
+ end
223
+ ```
224
+
225
+ Available letter casing settings are:
226
+ ```ruby
227
+ :up # change to small case
228
+ :down # change to upper case
229
+ :capitalize # capitalize each word
230
+ ```
231
+
232
+ Available whitespace settings are:
233
+ ```ruby
234
+ :trim # remove whitespace from both ends of the input
235
+ :chomp # remove whitespace at the end of input
236
+ :collapse # reduce all whitespace to single character
237
+ :remove # remove all whitespace
238
+ ```
239
+
240
+ #### 2.2.6 required
241
+
242
+ To ensure that input is provided use `:required` option:
243
+
244
+ ```ruby
245
+ prompt.ask("What's your phone number?", required: true)
246
+ # What's your phone number?
247
+ # >> No value provided for required
248
+ ```
249
+
250
+ #### 2.2.7 validate
251
+
252
+ In order to validate that input matches a given patter you can pass the `validate` option. Validate setting accepts `Regex`, `Proc` or `Symbol`.
253
+
254
+ ```ruby
255
+ prompt.ask('What is your username?') do |q|
256
+ q.validate /^[^\.]+\.[^\.]+/
257
+ end
258
+ ```
259
+
260
+ The **TTY::Prompt** comes with bult-in validations for `:email` and you can use them directly like so:
261
+
262
+ ```prompt
263
+ prompt.ask('What is your email?') { |q| q.validate :email }
264
+ ```
265
+
266
+ ### 2.3 keypress
267
+
268
+ In order to ask question with a single character or keypress answer use `ask_keypress`:
269
+
270
+ ```ruby
271
+ prompt.ask_keypress("Which one do you prefer a, b, c or d ?")
168
272
  ```
169
273
 
170
- ### 2.2 select
274
+ ### 2.4 multiline
275
+
276
+ Asking for multiline input can be done with `ask_multiline` method.
277
+
278
+ ```ruby
279
+ prompt.ask_multiline("Provide description?")
280
+ ```
281
+
282
+ The reading of input will terminate when empty line is submitted.
283
+
284
+
285
+ ### 2.5 mask
286
+
287
+ 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.
288
+
289
+ ```ruby
290
+ prompt.mask('What is your secret?')
291
+ # => What is your secret? ••••
292
+ ```
293
+
294
+ The masking character can be changed by passing `:mask` option:
295
+
296
+ ```ruby
297
+ prompt.mask('What is your secret?', mask: '\u2665')
298
+ # => What is your secret? ♥♥♥♥♥
299
+ ```
300
+
301
+ If you don't wish to show any output use `:echo` option like so:
302
+
303
+ ```ruby
304
+ prompt.mask('What is your secret?', echo: false)
305
+ ```
306
+
307
+ ### 2.6 yes?/no?
308
+
309
+ In order to display a query asking for boolean input from user use `yes?` like so:
310
+
311
+ ```ruby
312
+ prompt.yes?('Do you like Ruby?')
313
+ # =>
314
+ # Do you like Ruby? (Y/n)
315
+ ```
316
+
317
+ the same can be achieved by using plain `ask`:
318
+
319
+ ```ruby
320
+ prompt.ask('Do you like Ruby? (Y/n)', convert: :bool)
321
+ ```
322
+
323
+ There is also the opposite for asking confirmation of negative option:
324
+
325
+ ```ruby
326
+ prompt.no?('Do you hate Ruby?')
327
+ # =>
328
+ # Do you like Ruby? (y/N)
329
+ ```
330
+
331
+ ### 2.7 select
171
332
 
172
333
  For asking questions involving list of options use `select` method by passing the question and possible choices:
173
334
 
@@ -246,7 +407,7 @@ prompt.select("Choose your destiny?", choices, help: "(Bash keyboard)")
246
407
  # Jax
247
408
  ```
248
409
 
249
- ### 2.3 multi_select
410
+ ### 2.8 multi_select
250
411
 
251
412
  For asking questions involving multiple selection list use `multi_select` method by passing the question and possible choices:
252
413
 
@@ -312,23 +473,7 @@ And when you press enter you will see the following selected:
312
473
  # => [{score: 20}, {score: 50}]
313
474
  ```
314
475
 
315
- ### 2.4 say
316
-
317
- To simply print message out to stdout use `say` like so:
318
-
319
- ```ruby
320
- prompt.say(...) # print message to stdout
321
- ```
322
-
323
- **TTY::Prompt** provides more specific versions of `say` method to better express intenation behind the message:
324
-
325
- ```ruby
326
- prompt.confirm # print message(s) in green
327
- prompt.warn # print message(s) in yellow
328
- prompt.error # print message(s) in red
329
- ```
330
-
331
- ### 2.5 suggest
476
+ ### 2.9 suggest
332
477
 
333
478
  To suggest possible matches for the user input use `suggest` method like so:
334
479
 
@@ -350,6 +495,42 @@ prompt.suggest('b', possible, indent: 4, single_text: 'Perhaps you meant?')
350
495
  # blame
351
496
  ```
352
497
 
498
+ ### 2.10 say
499
+
500
+ To simply print message out to stdout use `say` like so:
501
+
502
+ ```ruby
503
+ prompt.say(...)
504
+ ```
505
+
506
+ The `say` method also accepts option `:color` which supports all the colors provided by [pastel](https://github.com/peter-murach/pastel#3-supported-colors)
507
+
508
+ **TTY::Prompt** provides more specific versions of `say` method to better express intenation behind the message such as `ok`, `warn` and `error`.
509
+
510
+ ### 2.11 ok
511
+
512
+ Print message(s) in green do:
513
+
514
+ ```ruby
515
+ prompt.ok(...)
516
+ ```
517
+
518
+ ### 2.12 warn
519
+
520
+ Print message(s) in yellow do:
521
+
522
+ ```ruby
523
+ prompt.warn(...)
524
+ ```
525
+
526
+ ### 2.13 error
527
+
528
+ Print message(s) in red do:
529
+
530
+ ```ruby
531
+ prompt.error(...)
532
+ ```
533
+
353
534
  ## Contributing
354
535
 
355
536
  1. Fork it ( https://github.com/peter-murach/tty-prompt/fork )