highline_wrapper 1.3.0 → 2.0.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/Gemfile.lock +55 -45
- data/Guardfile +2 -2
- data/README.md +68 -12
- data/lib/highline_wrapper/checkbox_question.rb +2 -2
- data/lib/highline_wrapper/multiple_choice_question.rb +1 -1
- data/lib/highline_wrapper/open_ended_question.rb +2 -2
- data/lib/highline_wrapper/question.rb +2 -3
- data/lib/highline_wrapper/version.rb +1 -1
- data/lib/highline_wrapper/yes_no_question.rb +1 -1
- data/lib/highline_wrapper.rb +1 -1
- data/renovate.json +9 -0
- metadata +25 -21
- data/spec/highline_wrapper/checkbox_question_spec.rb +0 -226
- data/spec/highline_wrapper/multiple_choice_question_spec.rb +0 -226
- data/spec/highline_wrapper/open_ended_question_spec.rb +0 -108
- data/spec/highline_wrapper/question_spec.rb +0 -114
- data/spec/highline_wrapper/yes_no_question_spec.rb +0 -108
- data/spec/spec_helper.rb +0 -50
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2555420fa949c1eb531c1783ec99156b8937ba4c15cf1832a70ac0cac353ed9f
|
4
|
+
data.tar.gz: '08ab9f56f86df8686b84c2d7b7ef0b0b4e7681c325d7815d250da4aa88ce7c9e'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 99861a049ee6c0d92d7bc6147613381cd96a69c4b74f3881193cac6fbe4fd2cf22e3bbeffa3f5d7aca9137a7ee3892783934112e5f017c6274a8ae34f6c90531
|
7
|
+
data.tar.gz: dc5c3507559c75ec84372c12186cfaf32180095c6a427f9d5dd739e266cf28e55c1aebe65a7f62fd0abf90bc84d99184cc3dcd86055c88498347fde185a6ec4b
|
data/Gemfile.lock
CHANGED
@@ -1,27 +1,29 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
highline_wrapper (1.3.
|
5
|
-
|
4
|
+
highline_wrapper (1.3.2.pre.test)
|
5
|
+
abbrev (~> 0.1)
|
6
|
+
highline (~> 3.0)
|
6
7
|
|
7
8
|
GEM
|
8
9
|
remote: https://rubygems.org/
|
9
10
|
specs:
|
11
|
+
abbrev (0.1.2)
|
10
12
|
ast (2.4.2)
|
11
13
|
coderay (1.1.3)
|
12
|
-
concurrent-ruby (1.
|
13
|
-
diff-lcs (1.
|
14
|
-
faker (2.
|
15
|
-
i18n (>= 1.
|
16
|
-
ffi (1.
|
17
|
-
formatador (
|
18
|
-
guard (2.
|
14
|
+
concurrent-ruby (1.2.3)
|
15
|
+
diff-lcs (1.5.1)
|
16
|
+
faker (3.2.3)
|
17
|
+
i18n (>= 1.8.11, < 2)
|
18
|
+
ffi (1.16.3)
|
19
|
+
formatador (1.1.0)
|
20
|
+
guard (2.18.1)
|
19
21
|
formatador (>= 0.2.4)
|
20
22
|
listen (>= 2.7, < 4.0)
|
21
23
|
lumberjack (>= 1.0.12, < 2.0)
|
22
24
|
nenv (~> 0.1)
|
23
25
|
notiffany (~> 0.0)
|
24
|
-
pry (>= 0.
|
26
|
+
pry (>= 0.13.0)
|
25
27
|
shellany (~> 0.0)
|
26
28
|
thor (>= 0.18.1)
|
27
29
|
guard-compat (1.2.1)
|
@@ -29,65 +31,73 @@ GEM
|
|
29
31
|
guard (~> 2.1)
|
30
32
|
guard-compat (~> 1.1)
|
31
33
|
rspec (>= 2.99.0, < 4.0)
|
32
|
-
highline (
|
33
|
-
i18n (1.
|
34
|
+
highline (3.0.1)
|
35
|
+
i18n (1.14.1)
|
34
36
|
concurrent-ruby (~> 1.0)
|
35
|
-
|
37
|
+
json (2.7.1)
|
38
|
+
language_server-protocol (3.17.0.3)
|
39
|
+
listen (3.8.0)
|
36
40
|
rb-fsevent (~> 0.10, >= 0.10.3)
|
37
41
|
rb-inotify (~> 0.9, >= 0.9.10)
|
38
|
-
lumberjack (1.2.
|
42
|
+
lumberjack (1.2.10)
|
39
43
|
method_source (1.0.0)
|
40
44
|
nenv (0.3.0)
|
41
45
|
notiffany (0.1.3)
|
42
46
|
nenv (~> 0.1)
|
43
47
|
shellany (~> 0.0)
|
44
|
-
parallel (1.
|
45
|
-
parser (3.0.
|
48
|
+
parallel (1.24.0)
|
49
|
+
parser (3.3.0.5)
|
46
50
|
ast (~> 2.4.1)
|
47
|
-
|
51
|
+
racc
|
52
|
+
pry (0.14.2)
|
48
53
|
coderay (~> 1.1)
|
49
54
|
method_source (~> 1.0)
|
50
|
-
|
51
|
-
|
55
|
+
racc (1.7.3)
|
56
|
+
rainbow (3.1.1)
|
57
|
+
rb-fsevent (0.11.2)
|
52
58
|
rb-inotify (0.10.1)
|
53
59
|
ffi (~> 1.0)
|
54
|
-
regexp_parser (2.
|
55
|
-
rexml (3.2.
|
56
|
-
rspec (3.
|
57
|
-
rspec-core (~> 3.
|
58
|
-
rspec-expectations (~> 3.
|
59
|
-
rspec-mocks (~> 3.
|
60
|
-
rspec-core (3.
|
61
|
-
rspec-support (~> 3.
|
62
|
-
rspec-expectations (3.
|
60
|
+
regexp_parser (2.9.0)
|
61
|
+
rexml (3.2.6)
|
62
|
+
rspec (3.13.0)
|
63
|
+
rspec-core (~> 3.13.0)
|
64
|
+
rspec-expectations (~> 3.13.0)
|
65
|
+
rspec-mocks (~> 3.13.0)
|
66
|
+
rspec-core (3.13.0)
|
67
|
+
rspec-support (~> 3.13.0)
|
68
|
+
rspec-expectations (3.13.0)
|
63
69
|
diff-lcs (>= 1.2.0, < 2.0)
|
64
|
-
rspec-support (~> 3.
|
65
|
-
rspec-mocks (3.
|
70
|
+
rspec-support (~> 3.13.0)
|
71
|
+
rspec-mocks (3.13.0)
|
66
72
|
diff-lcs (>= 1.2.0, < 2.0)
|
67
|
-
rspec-support (~> 3.
|
68
|
-
rspec-support (3.
|
69
|
-
rubocop (1.
|
73
|
+
rspec-support (~> 3.13.0)
|
74
|
+
rspec-support (3.13.0)
|
75
|
+
rubocop (1.60.2)
|
76
|
+
json (~> 2.3)
|
77
|
+
language_server-protocol (>= 3.17.0)
|
70
78
|
parallel (~> 1.10)
|
71
|
-
parser (>= 3.
|
79
|
+
parser (>= 3.3.0.2)
|
72
80
|
rainbow (>= 2.2.2, < 4.0)
|
73
81
|
regexp_parser (>= 1.8, < 3.0)
|
74
|
-
rexml
|
75
|
-
rubocop-ast (>= 1.
|
82
|
+
rexml (>= 3.2.5, < 4.0)
|
83
|
+
rubocop-ast (>= 1.30.0, < 2.0)
|
76
84
|
ruby-progressbar (~> 1.7)
|
77
|
-
unicode-display_width (>=
|
78
|
-
rubocop-ast (1.
|
79
|
-
parser (>= 3.
|
80
|
-
ruby-progressbar (1.
|
85
|
+
unicode-display_width (>= 2.4.0, < 3.0)
|
86
|
+
rubocop-ast (1.30.0)
|
87
|
+
parser (>= 3.2.1.0)
|
88
|
+
ruby-progressbar (1.13.0)
|
81
89
|
shellany (0.0.1)
|
82
|
-
thor (1.
|
83
|
-
unicode-display_width (2.
|
90
|
+
thor (1.3.0)
|
91
|
+
unicode-display_width (2.5.0)
|
84
92
|
|
85
93
|
PLATFORMS
|
86
|
-
|
94
|
+
arm64-darwin-21
|
95
|
+
arm64-darwin-22
|
96
|
+
arm64-darwin-23
|
87
97
|
|
88
98
|
DEPENDENCIES
|
89
99
|
bundler (~> 2.2)
|
90
|
-
faker (~>
|
100
|
+
faker (~> 3.0)
|
91
101
|
guard-rspec (~> 4.3)
|
92
102
|
highline_wrapper!
|
93
103
|
pry (~> 0.13)
|
@@ -95,4 +105,4 @@ DEPENDENCIES
|
|
95
105
|
rubocop (~> 1.10)
|
96
106
|
|
97
107
|
BUNDLED WITH
|
98
|
-
2.
|
108
|
+
2.5.4
|
data/Guardfile
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
guard :rspec, cmd: 'bundle exec rspec', all_on_start: true do
|
4
|
+
watch('spec/spec_helper.rb') { 'spec' }
|
5
|
+
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
4
6
|
watch(%r{^spec/.+_spec\.rb$})
|
5
|
-
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
6
|
-
watch('spec/spec_helper.rb') { 'spec' }
|
7
7
|
end
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Highline Wrapper
|
1
|
+
# Highline Wrapper
|
2
2
|
|
3
3
|
A little wrapper to help ask some easy questions via the command-line with Highline. The types of questions this wrapper supports is:
|
4
4
|
|
@@ -46,17 +46,17 @@ Then, you can call its questions to receive answers. There's several configurati
|
|
46
46
|
### Open-ended questions
|
47
47
|
|
48
48
|
Question configuration options:
|
49
|
-
* `indicate_default_message`: defaults to `true`
|
50
|
-
* `secret`: defaults to `false`
|
51
49
|
* `default`: defaults to `''`
|
50
|
+
* `indicate_default_message`: defaults to `true`
|
52
51
|
* `required`: defaults to `false`
|
52
|
+
* `secret`: defaults to `false`
|
53
53
|
|
54
54
|
Notes:
|
55
|
+
* If `default` is `''` and `required` is `false`, and the user skips the question, the answer will be `''`
|
55
56
|
* If `indicate_default_message` is `true`, then the wrapper will tell us what the default value returned is _if_ the user skips the question
|
56
57
|
* If `secret` is `true`, then the wrapper _may_ automatically add a newline after a skipped answer... this is automatic from HighLine and is, unfortunately, out of the wrapper's control
|
57
58
|
* If `required` is `true`, the question will repeat until the user answers the question
|
58
59
|
* If `required` is `true`, then the `default` value will be ignored (defaults to `''`, but could be set to whatever and the code won't care... the question is required)
|
59
|
-
* If `default` is `''` and `required` is `false`, and the user skips the question, the answer will be `''`
|
60
60
|
* If `secret` is `true`, then the command-line will hide the user's answer behind `*`
|
61
61
|
|
62
62
|
<details><summary>Examples</summary>
|
@@ -69,36 +69,51 @@ four
|
|
69
69
|
|
70
70
|
> HighlineWrapper.new.ask('What is your favorite number?', {required: true})
|
71
71
|
What is your favorite number?
|
72
|
+
|
72
73
|
--- This question is required ---
|
74
|
+
|
73
75
|
What is your favorite number?
|
76
|
+
|
74
77
|
--- This question is required ---
|
78
|
+
|
75
79
|
What is your favorite number?
|
80
|
+
|
76
81
|
--- This question is required ---
|
82
|
+
|
77
83
|
What is your favorite number?
|
78
84
|
2
|
79
85
|
=> "2"
|
80
86
|
|
81
87
|
> HighlineWrapper.new.ask('What is your favorite number?', {required: true, indicate_default_message: false})
|
82
88
|
What is your favorite number?
|
89
|
+
|
83
90
|
--- This question is required ---
|
91
|
+
|
84
92
|
What is your favorite number?
|
93
|
+
|
85
94
|
--- This question is required ---
|
95
|
+
|
86
96
|
What is your favorite number?
|
87
97
|
5
|
88
98
|
=> "5"
|
89
99
|
|
90
100
|
> HighlineWrapper.new.ask('What is your favorite number?', {indicate_default_message: false})
|
91
101
|
What is your favorite number?
|
102
|
+
|
92
103
|
=> ""
|
93
104
|
|
94
105
|
> HighlineWrapper.new.ask('What is your favorite color?')
|
95
106
|
What is your favorite color?
|
107
|
+
|
96
108
|
--- Default selected: EMPTY ---
|
109
|
+
|
97
110
|
=> ""
|
98
111
|
|
99
112
|
> HighlineWrapper.new.ask('What is your favorite color?', {default: 'orange'})
|
100
113
|
What is your favorite color?
|
114
|
+
|
101
115
|
--- Default selected: orange ---
|
116
|
+
|
102
117
|
=> "orange"
|
103
118
|
|
104
119
|
> HighlineWrapper.new.ask('Please type your private token:', {secret: true})
|
@@ -115,9 +130,11 @@ Please type your private token:
|
|
115
130
|
Please type your private token:
|
116
131
|
|
117
132
|
--- This question is required ---
|
133
|
+
|
118
134
|
Please type your private token:
|
119
135
|
|
120
136
|
--- This question is required ---
|
137
|
+
|
121
138
|
Please type your private token:
|
122
139
|
****************
|
123
140
|
=> "MY-PRIVATE-TOKEN"
|
@@ -134,15 +151,15 @@ Please type your private token:
|
|
134
151
|
### Yes/No questions
|
135
152
|
|
136
153
|
Question configuration options:
|
137
|
-
* `indicate_default_message`: defaults to `true`
|
138
154
|
* `default`: defaults to `true` (aka 'yes')
|
155
|
+
* `indicate_default_message`: defaults to `true`
|
139
156
|
* `required`: defaults to `false`
|
140
157
|
|
141
158
|
Notes:
|
159
|
+
* If `default` is `true` and `required` is `false`, and the user skips the question, the answer will be `true`
|
142
160
|
* If `indicate_default_message` is `true`, then the wrapper will tell us what the default value returned is _if_ the user skips the question
|
143
161
|
* If `required` is `true`, the question will repeat until the user answers the question
|
144
162
|
* If `required` is `true`, then the `default` value will be ignored (defaults to `true`, but could be set to whatever and the code won't care... the question is required)
|
145
|
-
* If `default` is `true` and `required` is `false`, and the user skips the question, the answer will be `true`
|
146
163
|
* The response to the question MUST be given either as `y`/`n`/`yes`/`no` or with any capitalization... anything else given as a response will be unparseable
|
147
164
|
|
148
165
|
<details><summary>Examples</summary>
|
@@ -150,7 +167,9 @@ Notes:
|
|
150
167
|
```ruby
|
151
168
|
> HighlineWrapper.new.ask_yes_no('Do you like Ruby?')
|
152
169
|
Do you like Ruby?
|
170
|
+
|
153
171
|
--- Default selected: YES ---
|
172
|
+
|
154
173
|
=> true
|
155
174
|
|
156
175
|
> HighlineWrapper.new.ask_yes_no('Do you like Ruby?', {indicate_default_message: false})
|
@@ -164,16 +183,24 @@ no
|
|
164
183
|
|
165
184
|
> HighlineWrapper.new.ask_yes_no('Do you like Ruby?', {default: false})
|
166
185
|
Do you like Ruby?
|
186
|
+
|
167
187
|
--- Default selected: NO ---
|
188
|
+
|
168
189
|
=> false
|
169
190
|
|
170
191
|
> HighlineWrapper.new.ask_yes_no('Do you like Ruby?', {required: true})
|
171
192
|
Do you like Ruby?
|
193
|
+
|
172
194
|
--- This question is required ---
|
195
|
+
|
173
196
|
Do you like Ruby?
|
197
|
+
|
174
198
|
--- This question is required ---
|
199
|
+
|
175
200
|
Do you like Ruby?
|
201
|
+
|
176
202
|
--- This question is required ---
|
203
|
+
|
177
204
|
Do you like Ruby?
|
178
205
|
N
|
179
206
|
=> false
|
@@ -182,6 +209,7 @@ N
|
|
182
209
|
Do you like Ruby?
|
183
210
|
uh-huh
|
184
211
|
--- This question is required ---
|
212
|
+
|
185
213
|
Do you like Ruby?
|
186
214
|
YES
|
187
215
|
=> true
|
@@ -190,6 +218,7 @@ YES
|
|
190
218
|
Do you like Ruby?
|
191
219
|
yep
|
192
220
|
--- This question is required ---
|
221
|
+
|
193
222
|
Do you like Ruby?
|
194
223
|
yes
|
195
224
|
=> true
|
@@ -200,16 +229,16 @@ yes
|
|
200
229
|
### Multiple choice questions
|
201
230
|
|
202
231
|
Question configuration options:
|
203
|
-
* `indicate_default_message`: defaults to `true`
|
204
|
-
* `with_index`: defaults to `false` (particularly handy when there may be duplicate-named but different items in the list—think Sally with ID 45 and Sally with ID 72)
|
205
232
|
* `default`: defaults to `nil`
|
233
|
+
* `indicate_default_message`: defaults to `true`
|
206
234
|
* `required`: defaults to `false`
|
235
|
+
* `with_index`: defaults to `false` (particularly handy when there may be duplicate-named but different items in the list—think Sally with ID 45 and Sally with ID 72)
|
207
236
|
|
208
237
|
Notes:
|
238
|
+
* If `default` is `nil` and `required` is `false`, and the user skips the question, the answer will be `nil`
|
209
239
|
* If `indicate_default_message` is `true`, then the wrapper will tell us what the default value returned is _if_ the user skips the question
|
210
240
|
* If `required` is `true`, the question will repeat until the user answers the question
|
211
241
|
* If `required` is `true`, then the `default` value will be ignored (defaults to `nil`, but could be set to whatever and the code won't care... the question is required)
|
212
|
-
* If `default` is `nil` and `required` is `false`, and the user skips the question, the answer will be `nil`
|
213
242
|
* If `with_index` is `true`, a hash will be returned with the choice AND the index of the selection in the original `choices` array
|
214
243
|
* e.g. `{ value: 'c', index: 2 }`
|
215
244
|
* If `with_index` is `false`, then a hash of one item will be returned
|
@@ -239,12 +268,16 @@ What is your favorite number of these?
|
|
239
268
|
1. one
|
240
269
|
2. two
|
241
270
|
3. three
|
271
|
+
|
242
272
|
--- This question is required ---
|
273
|
+
|
243
274
|
What is your favorite number of these?
|
244
275
|
1. one
|
245
276
|
2. two
|
246
277
|
3. three
|
278
|
+
|
247
279
|
--- This question is required ---
|
280
|
+
|
248
281
|
What is your favorite number of these?
|
249
282
|
1. one
|
250
283
|
2. two
|
@@ -257,7 +290,9 @@ What is your favorite number of these?
|
|
257
290
|
1. one
|
258
291
|
2. two
|
259
292
|
3. three
|
293
|
+
|
260
294
|
--- Default selected: 1. one ---
|
295
|
+
|
261
296
|
=> {:value=>"one", :index=>0}
|
262
297
|
|
263
298
|
> HighlineWrapper.new.ask_multiple_choice('What is your favorite number of these?', ['one', 'two', 'three'], {with_index: true, default: 'one', indicate_default_message: false})
|
@@ -272,12 +307,16 @@ What is your favorite number of these?
|
|
272
307
|
1. one
|
273
308
|
2. two
|
274
309
|
3. three
|
310
|
+
|
275
311
|
--- This question is required ---
|
312
|
+
|
276
313
|
What is your favorite number of these?
|
277
314
|
1. one
|
278
315
|
2. two
|
279
316
|
3. three
|
317
|
+
|
280
318
|
--- This question is required ---
|
319
|
+
|
281
320
|
What is your favorite number of these?
|
282
321
|
1. one
|
283
322
|
2. two
|
@@ -290,7 +329,9 @@ What is your favorite number of these?
|
|
290
329
|
1. one
|
291
330
|
2. two
|
292
331
|
3. three
|
332
|
+
|
293
333
|
--- Default selected: EMPTY ---
|
334
|
+
|
294
335
|
=> nil
|
295
336
|
|
296
337
|
> HighlineWrapper.new.ask_multiple_choice('What is your favorite number of these?', ['one', 'two', 'three'], {default: nil, with_index: true})
|
@@ -298,7 +339,9 @@ What is your favorite number of these?
|
|
298
339
|
1. one
|
299
340
|
2. two
|
300
341
|
3. three
|
342
|
+
|
301
343
|
--- Default selected: EMPTY ---
|
344
|
+
|
302
345
|
=> nil
|
303
346
|
|
304
347
|
> HighlineWrapper.new.ask_multiple_choice('What is your favorite number of these?', ['one', 'two', 'three'], {default: nil, with_index: true, indicate_default_message: false})
|
@@ -306,6 +349,7 @@ What is your favorite number of these?
|
|
306
349
|
1. one
|
307
350
|
2. two
|
308
351
|
3. three
|
352
|
+
|
309
353
|
=> nil
|
310
354
|
```
|
311
355
|
|
@@ -314,16 +358,16 @@ What is your favorite number of these?
|
|
314
358
|
### Multiple choice "checkbox" questions
|
315
359
|
|
316
360
|
Question configuration options:
|
317
|
-
* `indicate_default_message`: defaults to `true`
|
318
|
-
* `with_indexes`: defaults to `false` (particularly handy when there may be duplicate-named but different items in the list—think Sally with ID 45 and Sally with ID 72)
|
319
361
|
* `defaults`: defaults to `[]`
|
362
|
+
* `indicate_default_message`: defaults to `true`
|
320
363
|
* `required`: defaults to `false`
|
364
|
+
* `with_indexes`: defaults to `false` (particularly handy when there may be duplicate-named but different items in the list—think Sally with ID 45 and Sally with ID 72)
|
321
365
|
|
322
366
|
Notes:
|
367
|
+
* If `defaults` is `[]` and `required` is `false`, then the method will return an empty array
|
323
368
|
* If `indicate_default_message` is `true`, then the wrapper will tell us what the default value returned is _if_ the user skips the question
|
324
369
|
* If `required` is `true`, the question will repeat until the user answers the question
|
325
370
|
* If `required` is `true`, then the `defaults` value will be ignored (this value is defaulting to `[]`, but could be set to whatever and the code won't care... the question is required)
|
326
|
-
* If `defaults` is `[]` and `required` is `false`, then the method will return an empty array
|
327
371
|
* If `with_indexes` is `true`, an array of hashes will be returned with the choice AND the index (of the selection in the original `choices` array) in each hash
|
328
372
|
* e.g. `[{ value: 'a', index: 0 }, { value: 'c', index: 2 }]`
|
329
373
|
* If `with_indexes` is `false`, then an hashes will be returned where each hash only has a value
|
@@ -353,6 +397,7 @@ What are your favorite numbers of these?
|
|
353
397
|
1. one
|
354
398
|
2. two
|
355
399
|
3. three
|
400
|
+
|
356
401
|
=> []
|
357
402
|
|
358
403
|
> HighlineWrapper.new.ask_checkbox("What are your favorite numbers of these?", ['one', 'two','three'], {with_indexes: true})
|
@@ -360,7 +405,9 @@ What are your favorite numbers of these?
|
|
360
405
|
1. one
|
361
406
|
2. two
|
362
407
|
3. three
|
408
|
+
|
363
409
|
--- Defaults selected: EMPTY ---
|
410
|
+
|
364
411
|
=> []
|
365
412
|
|
366
413
|
> HighlineWrapper.new.ask_checkbox("What are your favorite numbers of these?", ['one', 'two','three'], {defaults: ['two', 'three']})
|
@@ -368,7 +415,9 @@ What are your favorite numbers of these?
|
|
368
415
|
1. one
|
369
416
|
2. two
|
370
417
|
3. three
|
418
|
+
|
371
419
|
--- Defaults selected: 2. two, 3. three ---
|
420
|
+
|
372
421
|
=> [{:value=>"two"}, {:value=>"three"}]
|
373
422
|
|
374
423
|
> HighlineWrapper.new.ask_checkbox("What are your favorite numbers of these?", ['one', 'two','three'], {required: true, with_indexes: true})
|
@@ -376,12 +425,16 @@ What are your favorite numbers of these?
|
|
376
425
|
1. one
|
377
426
|
2. two
|
378
427
|
3. three
|
428
|
+
|
379
429
|
--- This question is required ---
|
430
|
+
|
380
431
|
What are your favorite numbers of these?
|
381
432
|
1. one
|
382
433
|
2. two
|
383
434
|
3. three
|
435
|
+
|
384
436
|
--- This question is required ---
|
437
|
+
|
385
438
|
What are your favorite numbers of these?
|
386
439
|
1. one
|
387
440
|
2. two
|
@@ -394,7 +447,9 @@ What are your favorite numbers of these?
|
|
394
447
|
1. one
|
395
448
|
2. two
|
396
449
|
3. three
|
450
|
+
|
397
451
|
--- This question is required ---
|
452
|
+
|
398
453
|
What are your favorite numbers of these?
|
399
454
|
1. one
|
400
455
|
2. two
|
@@ -407,6 +462,7 @@ What are your favorite numbers of these?
|
|
407
462
|
1. one
|
408
463
|
2. two
|
409
464
|
3. three
|
465
|
+
|
410
466
|
=> [{:value=>"two", :index=>1}, {:value=>"three", :index=>2}]
|
411
467
|
```
|
412
468
|
|
@@ -17,7 +17,7 @@ class HighlineWrapper
|
|
17
17
|
|
18
18
|
private def ask_highline(prompt)
|
19
19
|
indices = []
|
20
|
-
super(prompt).to_s.split(',').each { |i| indices << i.strip.to_i - 1 }
|
20
|
+
super(prompt).to_s.split(',').each { |i| indices << (i.strip.to_i - 1) }
|
21
21
|
indices
|
22
22
|
end
|
23
23
|
|
@@ -29,7 +29,7 @@ class HighlineWrapper
|
|
29
29
|
|
30
30
|
private def print_default_message(options, choices)
|
31
31
|
defaults = options[:default_indexes].map { |i| "#{i + 1}. #{choices[i]}".strip }.join(', ')
|
32
|
-
puts "--- Defaults selected: #{defaults}
|
32
|
+
puts "--- Defaults selected: #{defaults} ---\n\n"
|
33
33
|
end
|
34
34
|
|
35
35
|
private def format_multiple_selections(choices, indices, with_indexes)
|
@@ -22,7 +22,7 @@ class HighlineWrapper
|
|
22
22
|
end
|
23
23
|
|
24
24
|
private def print_default_message(options)
|
25
|
-
puts "--- Default selected: #{options[:default_index] + 1}. #{options[:default]}
|
25
|
+
puts "--- Default selected: #{options[:default_index] + 1}. #{options[:default]} ---\n\n"
|
26
26
|
end
|
27
27
|
end
|
28
28
|
end
|
@@ -17,9 +17,9 @@ class HighlineWrapper
|
|
17
17
|
|
18
18
|
private def print_default_message(options)
|
19
19
|
if !options[:secret]
|
20
|
-
puts "--- Default selected: #{options[:default].empty? ? 'EMPTY' : options[:default]}
|
20
|
+
puts "--- Default selected: #{options[:default].empty? ? 'EMPTY' : options[:default]} ---\n\n"
|
21
21
|
elsif options[:secret]
|
22
|
-
puts
|
22
|
+
puts "--- Default selected: HIDDEN ---\n\n"
|
23
23
|
end
|
24
24
|
end
|
25
25
|
end
|
@@ -5,7 +5,6 @@ class HighlineWrapper
|
|
5
5
|
class << self
|
6
6
|
def ask_highline(prompt, secret: false)
|
7
7
|
highline.ask(prompt) do |conf|
|
8
|
-
conf.readline = true
|
9
8
|
conf.echo = '*' if secret
|
10
9
|
end
|
11
10
|
end
|
@@ -23,12 +22,12 @@ class HighlineWrapper
|
|
23
22
|
end
|
24
23
|
|
25
24
|
def recurse(prompt, choices, options)
|
26
|
-
puts
|
25
|
+
puts "--- This question is required ---\n\n"
|
27
26
|
choices.nil? ? ask(prompt, options) : ask(prompt, choices, options)
|
28
27
|
end
|
29
28
|
|
30
29
|
def return_empty_defaults(options)
|
31
|
-
puts
|
30
|
+
puts "--- Default selected: EMPTY ---\n\n" if options[:indicate_default_message]
|
32
31
|
options[:defaults] || options[:default]
|
33
32
|
end
|
34
33
|
|
data/lib/highline_wrapper.rb
CHANGED