tty-prompt 0.10.1 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +0 -1
  3. data/CHANGELOG.md +30 -0
  4. data/README.md +39 -9
  5. data/examples/echo.rb +5 -1
  6. data/examples/inputs.rb +10 -0
  7. data/examples/mask.rb +6 -2
  8. data/examples/multi_select.rb +1 -1
  9. data/examples/multi_select_paged.rb +9 -0
  10. data/examples/select.rb +5 -5
  11. data/examples/slider.rb +1 -1
  12. data/lib/tty-prompt.rb +2 -36
  13. data/lib/tty/prompt.rb +49 -8
  14. data/lib/tty/prompt/choices.rb +2 -0
  15. data/lib/tty/prompt/confirm_question.rb +6 -1
  16. data/lib/tty/prompt/converter_dsl.rb +9 -6
  17. data/lib/tty/prompt/converter_registry.rb +27 -19
  18. data/lib/tty/prompt/converters.rb +16 -22
  19. data/lib/tty/prompt/enum_list.rb +8 -4
  20. data/lib/tty/prompt/enum_paginator.rb +2 -0
  21. data/lib/tty/prompt/evaluator.rb +1 -1
  22. data/lib/tty/prompt/expander.rb +1 -1
  23. data/lib/tty/prompt/list.rb +21 -11
  24. data/lib/tty/prompt/mask_question.rb +15 -6
  25. data/lib/tty/prompt/multi_list.rb +12 -10
  26. data/lib/tty/prompt/question.rb +38 -36
  27. data/lib/tty/prompt/question/modifier.rb +2 -0
  28. data/lib/tty/prompt/question/validation.rb +5 -4
  29. data/lib/tty/prompt/reader.rb +104 -58
  30. data/lib/tty/prompt/reader/codes.rb +103 -63
  31. data/lib/tty/prompt/reader/console.rb +57 -0
  32. data/lib/tty/prompt/reader/key_event.rb +51 -88
  33. data/lib/tty/prompt/reader/mode.rb +5 -5
  34. data/lib/tty/prompt/reader/win_api.rb +29 -0
  35. data/lib/tty/prompt/reader/win_console.rb +49 -0
  36. data/lib/tty/prompt/slider.rb +10 -6
  37. data/lib/tty/prompt/suggestion.rb +1 -1
  38. data/lib/tty/prompt/symbols.rb +52 -10
  39. data/lib/tty/prompt/version.rb +1 -1
  40. data/lib/tty/{prompt/test.rb → test_prompt.rb} +2 -1
  41. data/spec/unit/ask_spec.rb +8 -16
  42. data/spec/unit/converters/convert_bool_spec.rb +1 -2
  43. data/spec/unit/converters/on_error_spec.rb +9 -0
  44. data/spec/unit/enum_paginator_spec.rb +16 -0
  45. data/spec/unit/enum_select_spec.rb +69 -25
  46. data/spec/unit/expand_spec.rb +14 -14
  47. data/spec/unit/mask_spec.rb +66 -29
  48. data/spec/unit/multi_select_spec.rb +120 -74
  49. data/spec/unit/new_spec.rb +5 -3
  50. data/spec/unit/paginator_spec.rb +16 -0
  51. data/spec/unit/question/default_spec.rb +2 -4
  52. data/spec/unit/question/echo_spec.rb +2 -3
  53. data/spec/unit/question/in_spec.rb +9 -14
  54. data/spec/unit/question/modifier/letter_case_spec.rb +32 -11
  55. data/spec/unit/question/modifier/whitespace_spec.rb +41 -15
  56. data/spec/unit/question/required_spec.rb +9 -13
  57. data/spec/unit/question/validate_spec.rb +7 -10
  58. data/spec/unit/reader/key_event_spec.rb +36 -50
  59. data/spec/unit/reader/publish_keypress_event_spec.rb +5 -3
  60. data/spec/unit/reader/read_keypress_spec.rb +8 -7
  61. data/spec/unit/reader/read_line_spec.rb +9 -9
  62. data/spec/unit/reader/read_multiline_spec.rb +8 -7
  63. data/spec/unit/select_spec.rb +85 -25
  64. data/spec/unit/slider_spec.rb +43 -16
  65. data/spec/unit/yes_no_spec.rb +14 -28
  66. data/tasks/console.rake +1 -0
  67. data/tty-prompt.gemspec +2 -2
  68. metadata +14 -7
@@ -2,6 +2,6 @@
2
2
 
3
3
  module TTY
4
4
  class Prompt
5
- VERSION = "0.10.1"
5
+ VERSION = "0.11.0"
6
6
  end # Prompt
7
7
  end # TTY
@@ -1,6 +1,6 @@
1
1
  # encoding: utf-8
2
2
 
3
- require 'tty/prompt'
3
+ require_relative 'prompt'
4
4
 
5
5
  module TTY
6
6
  # Used for initializing test cases
@@ -11,6 +11,7 @@ module TTY
11
11
  options.merge!({
12
12
  input: @input,
13
13
  output: @output,
14
+ env: { "TTY_TEST" => true },
14
15
  enable_color: options.fetch(:enable_color) { true }
15
16
  })
16
17
  super(options)
@@ -8,8 +8,7 @@ RSpec.describe TTY::Prompt, '#ask' do
8
8
  prompt.ask('What is your name?')
9
9
  expect(prompt.output.string).to eq([
10
10
  "What is your name? ",
11
- "\e[1000D\e[K\e[1A",
12
- "\e[1000D\e[K",
11
+ "\e[1A\e[2K\e[1G",
13
12
  "What is your name? \n"
14
13
  ].join)
15
14
  end
@@ -35,8 +34,7 @@ RSpec.describe TTY::Prompt, '#ask' do
35
34
  expect(answer).to eq(nil)
36
35
  expect(prompt.output.string).to eq([
37
36
  "[?] Are you Polish? ",
38
- "\e[1000D\e[K\e[1A",
39
- "\e[1000D\e[K",
37
+ "\e[1A\e[2K\e[1G",
40
38
  "[?] Are you Polish? \n"
41
39
  ].join)
42
40
  end
@@ -50,8 +48,7 @@ RSpec.describe TTY::Prompt, '#ask' do
50
48
  expect(answer).to eq('Piotr')
51
49
  expect(prompt.output.string).to eq([
52
50
  "What is your name? \e[90m(Piotr)\e[0m ",
53
- "\e[1000D\e[K\e[1A",
54
- "\e[1000D\e[K",
51
+ "\e[1A\e[2K\e[1G",
55
52
  "What is your name? \e[32mPiotr\e[0m\n"
56
53
  ].join)
57
54
  end
@@ -64,8 +61,7 @@ RSpec.describe TTY::Prompt, '#ask' do
64
61
  expect(answer).to eq('Piotr')
65
62
  expect(prompt.output.string).to eq([
66
63
  "What is your name? \e[31m(Piotr)\e[0m ",
67
- "\e[1000D\e[K\e[1A",
68
- "\e[1000D\e[K",
64
+ "\e[1A\e[2K\e[1G",
69
65
  "What is your name? \e[36mPiotr\e[0m\n"
70
66
  ].join)
71
67
  end
@@ -78,8 +74,7 @@ RSpec.describe TTY::Prompt, '#ask' do
78
74
  expect(answer).to eq('')
79
75
  expect(prompt.output.string).to eq([
80
76
  "What is your name? ",
81
- "\e[1000D\e[K\e[1A",
82
- "\e[1000D\e[K",
77
+ "\e[1A\e[2K\e[1G",
83
78
  "What is your name? \n"
84
79
  ].join)
85
80
  end
@@ -92,8 +87,7 @@ RSpec.describe TTY::Prompt, '#ask' do
92
87
  expect(answer).to eq(nil)
93
88
  expect(prompt.output.string).to eq([
94
89
  "What is your name? ",
95
- "\e[1000D\e[K\e[1A",
96
- "\e[1000D\e[K",
90
+ "\e[1A\e[2K\e[1G",
97
91
  "What is your name? \n"
98
92
  ].join)
99
93
  end
@@ -113,12 +107,10 @@ RSpec.describe TTY::Prompt, '#ask' do
113
107
 
114
108
  expect(prompt.output.string).to eq([
115
109
  "[?] What is your name? ",
116
- "\e[1000D\e[K\e[1A",
117
- "\e[1000D\e[K",
110
+ "\e[1A\e[2K\e[1G",
118
111
  "[?] What is your name? \e[36mPiotr\e[0m\n",
119
112
  ":-) What is your name? ",
120
- "\e[1000D\e[K\e[1A",
121
- "\e[1000D\e[K",
113
+ "\e[1A\e[2K\e[1G",
122
114
  ":-) What is your name? \e[34mPiotr\e[0m\n"
123
115
  ].join)
124
116
  end
@@ -19,8 +19,7 @@ RSpec.describe TTY::Prompt::Question, 'convert bool' do
19
19
  expect(response).to eql(true)
20
20
  expect(prompt.output.string).to eq([
21
21
  "Do you read books? \e[90m(true)\e[0m ",
22
- "\e[1000D\e[K\e[1A",
23
- "\e[1000D\e[K",
22
+ "\e[1A\e[2K\e[1G",
24
23
  "Do you read books? \e[32mtrue\e[0m\n"
25
24
  ].join)
26
25
  end
@@ -0,0 +1,9 @@
1
+ # encoding: utf-8
2
+
3
+ RSpec.describe TTY::Prompt::Converters do
4
+ it "enforces block argument" do
5
+ expect {
6
+ TTY::Prompt::Converters.on_error
7
+ }.to raise_error(ArgumentError, 'You need to provide a block argument.')
8
+ end
9
+ end
@@ -1,6 +1,22 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  RSpec.describe TTY::Prompt::EnumPaginator, '#paginate' do
4
+ it "ignores per_page when equal items " do
5
+ list = %w(a b c d)
6
+ paginator = described_class.new({per_page: 4})
7
+
8
+ expect(paginator.paginate(list, 1).to_a).to eq([
9
+ ['a',0],['b',1],['c',2],['d',3]])
10
+ end
11
+
12
+ it "ignores per_page when less items " do
13
+ list = %w(a b c d)
14
+ paginator = described_class.new({per_page: 5})
15
+
16
+ expect(paginator.paginate(list, 1).to_a).to eq([
17
+ ['a',0],['b',1],['c',2],['d',3]])
18
+ end
19
+
4
20
  it "paginates items matching per_page count" do
5
21
  list = %w(a b c d e f)
6
22
  paginator = described_class.new({per_page: 3})
@@ -1,8 +1,6 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  RSpec.describe TTY::Prompt do
4
- let(:page_help) {
5
- }
6
4
  it "selects default option when return pressed immediately" do
7
5
  prompt = TTY::TestPrompt.new
8
6
  choices = %w(/bin/nano /usr/bin/vim.basic /usr/bin/vim.tiny)
@@ -16,7 +14,8 @@ RSpec.describe TTY::Prompt do
16
14
  " 2) /usr/bin/vim.basic\n",
17
15
  " 3) /usr/bin/vim.tiny\n",
18
16
  " Choose 1-3 [1]: ",
19
- "\e[1000D\e[K\e[1A" * 4 + "\e[1000D\e[K\e[J",
17
+ "\e[2K\e[1G\e[1A" * 4,
18
+ "\e[2K\e[1G\e[J",
20
19
  "Select an editor? \e[32m/bin/nano\e[0m\n"
21
20
  ].join)
22
21
  end
@@ -34,20 +33,22 @@ RSpec.describe TTY::Prompt do
34
33
  "\e[32m 2) /usr/bin/vim.basic\e[0m\n",
35
34
  " 3) /usr/bin/vim.tiny\n",
36
35
  " Choose 1-3 [2]: ",
37
- "\e[1000D\e[K\e[1A" * 4 + "\e[1000D\e[K\e[J",
36
+ "\e[2K\e[1G\e[1A" * 4,
37
+ "\e[2K\e[1G\e[J",
38
38
  "Select an editor? \n",
39
39
  " 1) /bin/nano\n",
40
40
  " 2) /usr/bin/vim.basic\n",
41
41
  "\e[32m 3) /usr/bin/vim.tiny\e[0m\n",
42
42
  " Choose 1-3 [2]: 3",
43
- "\e[1000D\e[K\e[1A" * 4 + "\e[1000D\e[K\e[J",
43
+ "\e[2K\e[1G\e[1A" * 4,
44
+ "\e[2K\e[1G\e[J",
44
45
  "Select an editor? \e[32m/usr/bin/vim.tiny\e[0m\n"
45
46
  ].join)
46
47
  end
47
48
 
48
49
  it "selects option through DSL" do
49
50
  prompt = TTY::TestPrompt.new
50
- prompt.input << "\n"
51
+ prompt.input << "1\n"
51
52
  prompt.input.rewind
52
53
  value = prompt.enum_select("Select an editor?") do |menu|
53
54
  menu.default 2
@@ -58,15 +59,23 @@ RSpec.describe TTY::Prompt do
58
59
  menu.choice "/usr/bin/vim.tiny"
59
60
  end
60
61
 
61
- expect(value).to eq('/usr/bin/vim.basic')
62
+ expect(value).to eq('/bin/nano')
62
63
  expect(prompt.output.string).to eq([
63
64
  "Select an editor? \n",
64
65
  " 1. /bin/nano\n",
65
66
  "\e[32m 2. /usr/bin/vim.basic\e[0m\n",
66
67
  " 3. /usr/bin/vim.tiny\n",
67
68
  " Choose 1-3 [2]: ",
68
- "\e[1000D\e[K\e[1A\e[1000D\e[K\e[1A\e[1000D\e[K\e[1A\e[1000D\e[K\e[1A\e[1000D\e[K\e[J",
69
- "Select an editor? \e[32m/usr/bin/vim.basic\e[0m\n"
69
+ "\e[2K\e[1G\e[1A" * 4,
70
+ "\e[2K\e[1G\e[J",
71
+ "Select an editor? \n",
72
+ "\e[32m 1. /bin/nano\e[0m\n",
73
+ " 2. /usr/bin/vim.basic\n",
74
+ " 3. /usr/bin/vim.tiny\n",
75
+ " Choose 1-3 [2]: 1",
76
+ "\e[2K\e[1G\e[1A" * 4,
77
+ "\e[2K\e[1G\e[J",
78
+ "Select an editor? \e[32m/bin/nano\e[0m\n"
70
79
  ].join)
71
80
  end
72
81
 
@@ -89,7 +98,8 @@ RSpec.describe TTY::Prompt do
89
98
  "\e[32m 2) vim\e[0m\n",
90
99
  " 3) emacs\n",
91
100
  " Choose 1-3 [2]: ",
92
- "\e[1000D\e[K\e[1A\e[1000D\e[K\e[1A\e[1000D\e[K\e[1A\e[1000D\e[K\e[1A\e[1000D\e[K\e[J",
101
+ "\e[2K\e[1G\e[1A" * 4,
102
+ "\e[2K\e[1G\e[J",
93
103
  "Select an editor? \e[32mvim\e[0m\n"
94
104
  ].join)
95
105
  end
@@ -107,8 +117,8 @@ RSpec.describe TTY::Prompt do
107
117
  " 2) /usr/bin/vim.basic\n",
108
118
  " 3) /usr/bin/vim.tiny\n",
109
119
  " Choose 1-3 [1]: ",
110
- "\e[1000D\e[K\e[1A" * 4,
111
- "\e[1000D\e[K\e[J",
120
+ "\e[2K\e[1G\e[1A" * 4,
121
+ "\e[2K\e[1G\e[J",
112
122
  "Select an editor? \e[31m/bin/nano\e[0m\n"
113
123
  ].join)
114
124
  end
@@ -126,19 +136,22 @@ RSpec.describe TTY::Prompt do
126
136
  " 2) /usr/bin/vim.basic\n",
127
137
  " 3) /usr/bin/vim.tiny\n",
128
138
  " Choose 1-3 [1]: ",
129
- "\e[1000D\e[K\e[1A" * 4 + "\e[1000D\e[K\e[J",
139
+ "\e[2K\e[1G\e[1A" * 4,
140
+ "\e[2K\e[1G\e[J",
130
141
  "Select an editor? \n",
131
142
  "\e[32m 1) /bin/nano\e[0m\n",
132
143
  " 2) /usr/bin/vim.basic\n",
133
144
  " 3) /usr/bin/vim.tiny\n",
134
145
  " Choose 1-3 [1]: 1",
135
- "\e[1000D\e[K\e[1A" * 4 + "\e[1000D\e[K\e[J",
146
+ "\e[2K\e[1G\e[1A" * 4,
147
+ "\e[2K\e[1G\e[J",
136
148
  "Select an editor? \n",
137
149
  "\e[32m 1) /bin/nano\e[0m\n",
138
150
  " 2) /usr/bin/vim.basic\n",
139
151
  " 3) /usr/bin/vim.tiny\n",
140
152
  " Choose 1-3 [1]: 11",
141
- "\e[1000D\e[K\e[1A" * 4 + "\e[1000D\e[K\e[J",
153
+ "\e[2K\e[1G\e[1A" * 4,
154
+ "\e[2K\e[1G\e[J",
142
155
  "Select an editor? \n",
143
156
  "\e[32m 1) /bin/nano\e[0m\n",
144
157
  " 2) /usr/bin/vim.basic\n",
@@ -146,7 +159,8 @@ RSpec.describe TTY::Prompt do
146
159
  " Choose 1-3 [1]: \n",
147
160
  "\e[31m>>\e[0m Please enter a valid number",
148
161
  "\e[A\e[1G\e[18C",
149
- "\e[1000D\e[K\e[1A" * 4 + "\e[1000D\e[K\e[J",
162
+ "\e[2K\e[1G\e[1A" * 4,
163
+ "\e[2K\e[1G\e[J",
150
164
  "Select an editor? \n",
151
165
  " 1) /bin/nano\n",
152
166
  "\e[32m 2) /usr/bin/vim.basic\e[0m\n",
@@ -154,7 +168,8 @@ RSpec.describe TTY::Prompt do
154
168
  " Choose 1-3 [1]: 2\n",
155
169
  "\e[31m>>\e[0m Please enter a valid number",
156
170
  "\e[A\e[1G\e[19C",
157
- "\e[1000D\e[K\e[1A" * 4 + "\e[1000D\e[K\e[J",
171
+ "\e[2K\e[1G\e[1A" * 4,
172
+ "\e[2K\e[1G\e[J",
158
173
  "Select an editor? \e[32m/usr/bin/vim.basic\e[0m\n"
159
174
  ].join)
160
175
  end
@@ -174,11 +189,33 @@ RSpec.describe TTY::Prompt do
174
189
  " Choose 1-8 [4]: ",
175
190
  "\n\e[90m(Press tab/right or left to reveal more choices)\e[0m",
176
191
  "\e[A\e[1G\e[18C",
177
- "\e[1000D\e[K\e[1A" * 4 + "\e[1000D\e[K\e[J",
192
+ "\e[2K\e[1G\e[1A" * 4,
193
+ "\e[2K\e[1G\e[J",
178
194
  "What letter? \e[32mD\e[0m\n"
179
195
  ].join)
180
196
  end
181
197
 
198
+ it "doesn't paginate short selections" do
199
+ prompt = TTY::TestPrompt.new
200
+ choices = %w(A B C D)
201
+ prompt.input << "\r"
202
+ prompt.input.rewind
203
+ value = prompt.enum_select("What letter?", choices, per_page: 4, default: 1)
204
+ expect(value).to eq('A')
205
+
206
+ expect(prompt.output.string).to eq([
207
+ "What letter? \n",
208
+ "\e[32m 1) A\e[0m\n",
209
+ " 2) B\n",
210
+ " 3) C\n",
211
+ " 4) D\n",
212
+ " Choose 1-4 [1]: ",
213
+ "\e[2K\e[1G\e[1A" * 5,
214
+ "\e[2K\e[1G\e[J",
215
+ "What letter? \e[32mA\e[0m\n"
216
+ ].join)
217
+ end
218
+
182
219
  it "shows pages matching input" do
183
220
  prompt = TTY::TestPrompt.new
184
221
  choices = %w(A B C D E F G H)
@@ -194,7 +231,8 @@ RSpec.describe TTY::Prompt do
194
231
  " Choose 1-8 [1]: ",
195
232
  "\n\e[90m(Press tab/right or left to reveal more choices)\e[0m",
196
233
  "\e[A\e[1G\e[18C",
197
- "\e[1000D\e[K\e[1A" * 4 + "\e[1000D\e[K\e[J",
234
+ "\e[2K\e[1G\e[1A" * 4,
235
+ "\e[2K\e[1G\e[J",
198
236
  "What letter? \n",
199
237
  "\e[32m 1) A\e[0m\n",
200
238
  " 2) B\n",
@@ -202,7 +240,8 @@ RSpec.describe TTY::Prompt do
202
240
  " Choose 1-8 [1]: 1",
203
241
  "\n\e[90m(Press tab/right or left to reveal more choices)\e[0m",
204
242
  "\e[A\e[1G\e[19C",
205
- "\e[1000D\e[K\e[1A" * 4 + "\e[1000D\e[K\e[J",
243
+ "\e[2K\e[1G\e[1A" * 4,
244
+ "\e[2K\e[1G\e[J",
206
245
  "What letter? \n",
207
246
  "\e[32m 1) A\e[0m\n",
208
247
  " 2) B\n",
@@ -210,7 +249,8 @@ RSpec.describe TTY::Prompt do
210
249
  " Choose 1-8 [1]: 11",
211
250
  "\n\e[90m(Press tab/right or left to reveal more choices)\e[0m",
212
251
  "\e[A\e[1G\e[20C",
213
- "\e[1000D\e[K\e[1A" * 4 + "\e[1000D\e[K\e[J",
252
+ "\e[2K\e[1G\e[1A" * 4,
253
+ "\e[2K\e[1G\e[J",
214
254
  "What letter? \n",
215
255
  "\e[32m 1) A\e[0m\n",
216
256
  " 2) B\n",
@@ -219,7 +259,8 @@ RSpec.describe TTY::Prompt do
219
259
  "\e[31m>>\e[0m Please enter a valid number",
220
260
  "\n\e[90m(Press tab/right or left to reveal more choices)\e[0m",
221
261
  "\e[A\e[1G\e[A\e[1G\e[18C",
222
- "\e[1000D\e[K\e[1A" * 4 + "\e[1000D\e[K\e[J",
262
+ "\e[2K\e[1G\e[1A" * 4,
263
+ "\e[2K\e[1G\e[J",
223
264
  "What letter? \n",
224
265
  "\e[32m 1) A\e[0m\n",
225
266
  " 2) B\n",
@@ -228,7 +269,8 @@ RSpec.describe TTY::Prompt do
228
269
  "\e[31m>>\e[0m Please enter a valid number",
229
270
  "\n\e[90m(Press tab/right or left to reveal more choices)\e[0m",
230
271
  "\e[A\e[1G\e[A\e[1G\e[18C",
231
- "\e[1000D\e[K\e[1A" * 4 + "\e[1000D\e[K\e[J",
272
+ "\e[2K\e[1G\e[1A" * 4,
273
+ "\e[2K\e[1G\e[J",
232
274
  "What letter? \e[32mA\e[0m\n"
233
275
  ].join)
234
276
  end
@@ -252,14 +294,16 @@ RSpec.describe TTY::Prompt do
252
294
  " Choose 1-8 [4]: ",
253
295
  "\n\e[90m(Press tab/right or left to reveal more choices)\e[0m",
254
296
  "\e[A\e[1G\e[18C",
255
- "\e[1000D\e[K\e[1A" * 4 + "\e[1000D\e[K\e[J",
297
+ "\e[2K\e[1G\e[1A" * 4,
298
+ "\e[2K\e[1G\e[J",
256
299
  "What letter? \n",
257
300
  " 7) G\n",
258
301
  " 8) H\n",
259
302
  " Choose 1-8 [4]: ",
260
303
  "\n\e[90m(Press tab/right or left to reveal more choices)\e[0m",
261
304
  "\e[A\e[1G\e[18C",
262
- "\e[1000D\e[K\e[1A" * 3 + "\e[1000D\e[K\e[J",
305
+ "\e[2K\e[1G\e[1A" * 3,
306
+ "\e[2K\e[1G\e[J",
263
307
  "What letter? \e[32mD\e[0m\n"
264
308
  ].join)
265
309
  end
@@ -37,7 +37,7 @@ RSpec.describe TTY::Prompt, '#expand' do
37
37
 
38
38
  expect(prompt.output.string).to eq([
39
39
  "Overwrite Gemfile? (enter \"h\" for help) [\e[32my\e[0m,n,a,d,q,h] ",
40
- "\e[1000D\e[K",
40
+ "\e[2K\e[1G",
41
41
  "Overwrite Gemfile? \e[32mOverwrite\e[0m\n"
42
42
  ].join)
43
43
  end
@@ -51,7 +51,7 @@ RSpec.describe TTY::Prompt, '#expand' do
51
51
 
52
52
  expect(prompt.output.string).to eq([
53
53
  "Overwrite Gemfile? (enter \"h\" for help) [y,n,\e[32ma\e[0m,d,q,h] ",
54
- "\e[1000D\e[K",
54
+ "\e[2K\e[1G",
55
55
  "Overwrite Gemfile? \e[32mOverwrite all\e[0m\n"
56
56
  ].join)
57
57
  end
@@ -65,14 +65,14 @@ RSpec.describe TTY::Prompt, '#expand' do
65
65
 
66
66
  expect(prompt.output.string).to eq([
67
67
  "Overwrite Gemfile? (enter \"h\" for help) [\e[32my\e[0m,n,a,d,q,h] ",
68
- "\e[1000D\e[K",
68
+ "\e[2K\e[1G",
69
69
  "Overwrite Gemfile? (enter \"h\" for help) [y,n,\e[32ma\e[0m,d,q,h] ",
70
70
  "a\n",
71
71
  "\e[32m>> \e[0mOverwrite all",
72
72
  "\e[A\e[1G\e[55C",
73
- "\e[1000D\e[K",
73
+ "\e[2K\e[1G",
74
74
  "\e[1B",
75
- "\e[1000D\e[K",
75
+ "\e[2K\e[1G",
76
76
  "\e[A\e[1G",
77
77
  "Overwrite Gemfile? \e[32mOverwrite all\e[0m\n"
78
78
  ].join)
@@ -87,13 +87,13 @@ RSpec.describe TTY::Prompt, '#expand' do
87
87
 
88
88
  expect(prompt.output.string).to eq([
89
89
  "Overwrite Gemfile? (enter \"h\" for help) [\e[32my\e[0m,n,a,d,q,h] ",
90
- "\e[1000D\e[K",
90
+ "\e[2K\e[1G",
91
91
  "Overwrite Gemfile? (enter \"h\" for help) [y,n,a,d,q,\e[32mh\e[0m] h\n",
92
92
  "\e[32m>> \e[0mprint help",
93
93
  "\e[A\e[1G\e[55C",
94
- "\e[1000D\e[K",
94
+ "\e[2K\e[1G",
95
95
  "\e[1B",
96
- "\e[1000D\e[K",
96
+ "\e[2K\e[1G",
97
97
  "\e[A\e[1G",
98
98
  "Overwrite Gemfile? \n",
99
99
  " y - Overwrite\n",
@@ -103,8 +103,8 @@ RSpec.describe TTY::Prompt, '#expand' do
103
103
  " q - Quit\n",
104
104
  " h - print help\n",
105
105
  " Choice [y]: ",
106
- "\e[1000D\e[K\e[1A" * 7,
107
- "\e[1000D\e[K",
106
+ "\e[2K\e[1G\e[1A" * 7,
107
+ "\e[2K\e[1G",
108
108
  "Overwrite Gemfile? \n",
109
109
  " y - Overwrite\n",
110
110
  " n - Skip\n",
@@ -113,8 +113,8 @@ RSpec.describe TTY::Prompt, '#expand' do
113
113
  " q - Quit\n",
114
114
  " h - print help\n",
115
115
  " Choice [y]: d",
116
- "\e[1000D\e[K\e[1A" * 7,
117
- "\e[1000D\e[K",
116
+ "\e[2K\e[1G\e[1A" * 7,
117
+ "\e[2K\e[1G",
118
118
  "Overwrite Gemfile? \e[32mShow diff\e[0m\n",
119
119
  ].join)
120
120
  end
@@ -137,7 +137,7 @@ RSpec.describe TTY::Prompt, '#expand' do
137
137
 
138
138
  expect(prompt.output.string).to eq([
139
139
  "Overwrite Gemfile? (enter \"h\" for help) [y,n,a,\e[32md\e[0m,q,h] ",
140
- "\e[1000D\e[K",
140
+ "\e[2K\e[1G",
141
141
  "Overwrite Gemfile? \e[32mShow diff\e[0m\n"
142
142
  ].join)
143
143
  end
@@ -158,7 +158,7 @@ RSpec.describe TTY::Prompt, '#expand' do
158
158
 
159
159
  expect(prompt.output.string).to eq([
160
160
  "Overwrite Gemfile? (enter \"h\" for help) [\e[32my\e[0m,n,a,d,q,h] ",
161
- "\e[1000D\e[K",
161
+ "\e[2K\e[1G",
162
162
  "Overwrite Gemfile? \e[32mOverwrite\e[0m\n"
163
163
  ].join)
164
164
  end