tty-prompt 0.17.0 → 0.17.1
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/CHANGELOG.md +305 -0
- data/README.md +4 -0
- data/lib/tty/prompt/list.rb +23 -13
- data/lib/tty/prompt/multi_list.rb +2 -2
- data/lib/tty/prompt/version.rb +3 -1
- data/spec/unit/select_spec.rb +19 -0
- data/tty-prompt.gemspec +3 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: add9caacfddf9bf791d06ebc7a1c71bfe8b93bf9223a99ae7b44cd7e7db6bbc7
|
4
|
+
data.tar.gz: f438dccea904d0bcb7e8eda4aa5c4c3c9e1002dc26ab2e1afd75a8a8c9cad315
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3f3a0b45e1c57b370de325375698920ee07ea1e57cbfe8ac830cd38da5d1b8755e5ba4c844cfdea5a9fafe7c6744c5aaa199c13ff32e1f59bef41135bf23f7cd
|
7
|
+
data.tar.gz: 2fd7510bb85454bad9b089a6d2684418eb710ecbe49d3c423ffa118a8980e9fa9dd54e3f6ea5185334939d1fce3ff03abc489b3b1dad47d4304b3fcc4304cac3
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,305 @@
|
|
1
|
+
# Change log
|
2
|
+
|
3
|
+
## [v0.17.1] - 2018-10-03
|
4
|
+
|
5
|
+
### Change
|
6
|
+
* Change #select, #multi_select to allow alphanumeric, punctuation and space characters in filters
|
7
|
+
|
8
|
+
### Fixed
|
9
|
+
* Fix #select by making filter an array to avoid frozen string issues by Chris Hoffman(@yarmiganosca)
|
10
|
+
|
11
|
+
## [v0.17.0] - 2018-08-05
|
12
|
+
|
13
|
+
### Changed
|
14
|
+
* Change to update tty-reader & tty-cursor dependencies
|
15
|
+
* Change to directly requrie files in gemspec
|
16
|
+
|
17
|
+
## [v0.16.1] - 2018-04-29
|
18
|
+
|
19
|
+
### Fixed
|
20
|
+
* Fix key events subscription to only listen for the current prompt events
|
21
|
+
|
22
|
+
## [v0.16.0] - 2018-03-11
|
23
|
+
|
24
|
+
### Added
|
25
|
+
* Add :disabled key to Choice
|
26
|
+
* Add ability to disable choices in #select, #multi_selct & #enum_select prompts
|
27
|
+
* Add #frozen_string_literal to all files
|
28
|
+
|
29
|
+
### Changed
|
30
|
+
* Change Choice#from to allow parsing different data strucutures
|
31
|
+
* Change all classes to prevent strings mutations
|
32
|
+
* Change Timeout to cleanly terminate keypress input without raising errors
|
33
|
+
|
34
|
+
### Fixed
|
35
|
+
* Fix #select, #enum_select & #multi_select navigation to work correctly with items longer than terminal screen width
|
36
|
+
* Fix timeout on Ruby 2.5 and stop raising Timeout::Error
|
37
|
+
|
38
|
+
## [v0.15.0] - 2018-02-08
|
39
|
+
|
40
|
+
### Added
|
41
|
+
* Add ability to filter list items in #select, #multi_select & #enum_selct prompts by Saverio Miroddi(@saveriomiroddi)
|
42
|
+
* Add support for array of values for an answer collector key by Danny Hadley(@dadleyy)
|
43
|
+
|
44
|
+
### Changed
|
45
|
+
* Relax dependency on timers by Andy Brody(@brodygov)
|
46
|
+
|
47
|
+
## [v0.14.0] - 2018-01-01
|
48
|
+
|
49
|
+
### Added
|
50
|
+
* Add :cycle option to #select, #multi_select & #enum_select prompts to allow toggling between infinite and bounded list by Jonas Müller(@muellerj)
|
51
|
+
|
52
|
+
### Changed
|
53
|
+
* Change #multi_selct, #select & #enum_select to stop cycling options by default by Jona Müller(@muellerj)
|
54
|
+
* Change gemspec to require ruby >= 2.0.0
|
55
|
+
* Change #slider prompt to display slider next to query and help underneath
|
56
|
+
* Change to use tty-reader v0.2.0 with new line editing features for processing long inputs
|
57
|
+
|
58
|
+
### Fixed
|
59
|
+
* Fix Paginator & EnumPaginator to allow only positive integer values by Andy Brody(@ab)
|
60
|
+
* Fix EnumSelect to report on default option out of range and raise correctly
|
61
|
+
* Fix #ask :file & :path converters to correctly locate the files
|
62
|
+
* Fix #ask, #multiline to correctly handle long strings that wrap around screen
|
63
|
+
* Fix #slider prompt to correctly scale sliding
|
64
|
+
|
65
|
+
## [v0.13.2] - 2017-08-30
|
66
|
+
|
67
|
+
### Changed
|
68
|
+
* Change to extract TTY::Prompt::Reader to its own dependency
|
69
|
+
|
70
|
+
## [v0.13.1] - 2017-08-16
|
71
|
+
|
72
|
+
### Added
|
73
|
+
* Add ability to manually cancel the time scheduler
|
74
|
+
|
75
|
+
### Changed
|
76
|
+
* Change #keypress to use new scheduler cancelling
|
77
|
+
* Change Reader to inline interrupt to allow for early exit
|
78
|
+
|
79
|
+
### Fix
|
80
|
+
* Fix keypress reading on Windows to distinguish between blocking & non-blocking IO
|
81
|
+
|
82
|
+
## [v0.13.0] - 2017-08-11
|
83
|
+
|
84
|
+
### Changed
|
85
|
+
* Change Timeout to use clock time instead of sleep to measure interval
|
86
|
+
* Upgrade tty-cursor to fix save & restore
|
87
|
+
|
88
|
+
### Fixed
|
89
|
+
* Fix keypress with timeout option to cleanly stop timeout thread
|
90
|
+
* Fix Reader on Windows to stop blocking when waiting for key press
|
91
|
+
|
92
|
+
## [v0.12.0] - 2017-03-19
|
93
|
+
|
94
|
+
### Added
|
95
|
+
* Add Multiline question type
|
96
|
+
* Add Keypress question type
|
97
|
+
* Add Reader::History for storing buffered lines
|
98
|
+
* Add Reader::Line for line abstraction
|
99
|
+
|
100
|
+
### Changed
|
101
|
+
* Remove :read option from Question
|
102
|
+
* Chnage Reader#read_line to handle raw mode for processing special
|
103
|
+
characters such as Ctrl+x, navigate through history buffer
|
104
|
+
using up/down arrows, allow editing current line by moving left/right
|
105
|
+
with arrow keys and inserting content
|
106
|
+
* Change Reader#read_multiline to gather multi line input correctly,
|
107
|
+
skip empty lines and terminate when Ctrl+d and Ctrl+z are pressed
|
108
|
+
* Change Reader::Mode to check if tty is available by Matt Martyn (@MMartyn)
|
109
|
+
* Change #keypress prompt to correctly refresh line and accept :keys & :timeout options
|
110
|
+
|
111
|
+
### Fixed
|
112
|
+
* Fix issue with #select, #multi_selct, #enum_select when choices are
|
113
|
+
provided as hash object together with prompt options.
|
114
|
+
* Fix issue with default parameter for yes?/no? prompt by Carlos Fonseca (@carlosefonseca)
|
115
|
+
* Fix List#help to allow setting help text through DSL
|
116
|
+
|
117
|
+
## [v0.11.0] - 2017-02-26
|
118
|
+
|
119
|
+
### Added
|
120
|
+
* Add Console for reading input characters on Unix systems
|
121
|
+
* Add WinConsole for reading input characters on Windows systems
|
122
|
+
* Add WindowsApi to allow for calls to external Windows api
|
123
|
+
* Add echo support to multilist by Keith Keith T. Garner(@ktgeek)
|
124
|
+
|
125
|
+
### Changed
|
126
|
+
* Change Reader to use Console for input reading
|
127
|
+
* Change Codes to use codepoints instead of strings
|
128
|
+
* Change Reader#read_line to match #gets behaviour
|
129
|
+
* Change Symbols to provide Unicode support on windows
|
130
|
+
* Change Slider to display Unicode when possible
|
131
|
+
* Change ConverterRegistry to be immutable
|
132
|
+
* Change Reader to expose #trigger in place of #publish for events firing
|
133
|
+
|
134
|
+
### Fixed
|
135
|
+
* Fix `modify` throwing exception, when user enters empty input by Igor Rzegocki(@ajgon)
|
136
|
+
* Fix #clear_line behaviour by using tty-cursor 0.4.0 to work in all terminals
|
137
|
+
* Fix paging issue for lists shorter than :per_page value repeating title
|
138
|
+
* Fix #mask prompt to correctly match input on Windows
|
139
|
+
* Fix @mask to use default error messages
|
140
|
+
* Fix #select & #multi_select prompts to allow changing options with arrow keys on Windows
|
141
|
+
* Fix #echo to work correctly in zsh shell by štef(@d4be4st)
|
142
|
+
* Fix Slider#keyright event accepting max value outside of range
|
143
|
+
* Fix 2.4.0 conversion errors by using necromancer 0.4.0
|
144
|
+
* Fix #enum_select preventing selection of first item
|
145
|
+
|
146
|
+
## [v0.10.1] - 2017-02-06
|
147
|
+
|
148
|
+
### Fixed
|
149
|
+
* Fix File namespacing
|
150
|
+
|
151
|
+
## [v0.10.0] - 2017-01-01
|
152
|
+
|
153
|
+
### Added
|
154
|
+
* Add :enable_color option for toggling colors support
|
155
|
+
|
156
|
+
### Changed
|
157
|
+
* Update pastel dependency version
|
158
|
+
|
159
|
+
## [v0.9.0] - 2016-12-20
|
160
|
+
|
161
|
+
### Added
|
162
|
+
* Add ability to paginate choices list for #select, #multi_select & #enum_select
|
163
|
+
with :per_page, :page_info and :default options
|
164
|
+
* Add ability to switch through options in #select & #multi_select using the tab key
|
165
|
+
|
166
|
+
### Fixed
|
167
|
+
* Fix readers to accept multibyte characters reported by Jaehyun Shin(@keepcosmos)
|
168
|
+
|
169
|
+
## [v0.8.0] - 2016-11-29
|
170
|
+
|
171
|
+
### Added
|
172
|
+
* Add ability to publish custom key events for VIM keybindings customisations etc...
|
173
|
+
|
174
|
+
### Fixed
|
175
|
+
* Fix Reader#read_char to use Ruby internal buffers instead of direct system call by @kke(Kimmo Lehto)
|
176
|
+
* Fix issue with #ask required & validate checks to take into account required when validating values
|
177
|
+
* Fix bug with #read_keypress to handle function keys and meta navigation keys
|
178
|
+
* Fix issue with default messages not displaying for `range`, `required` and `validate`
|
179
|
+
|
180
|
+
## [v0.7.1] - 2016-08-07
|
181
|
+
|
182
|
+
### Fixed
|
183
|
+
* Fix Reader::Mode to include standard io library
|
184
|
+
|
185
|
+
## [v0.7.0] - 2016-07-17
|
186
|
+
|
187
|
+
### Added
|
188
|
+
* Add :interrupt_handler option to customise keyboard interrupt behaviour
|
189
|
+
|
190
|
+
### Changed
|
191
|
+
* Remove tty-platform dependency
|
192
|
+
|
193
|
+
### Fixed
|
194
|
+
* Fix Reader#read_keypress issue when handling interrupt signal by Ondrej Moravcik(@ondra-m)
|
195
|
+
* Fix raw & echo modes to use standard library support by Kim Burgestrand(@Burgestrand)
|
196
|
+
|
197
|
+
## [v0.6.0] - 2016-05-21
|
198
|
+
|
199
|
+
### Changed
|
200
|
+
* Upgrade tty-cursor dependency
|
201
|
+
|
202
|
+
### Fixed
|
203
|
+
* Fix issue with reader trapping signals by @kylekyle
|
204
|
+
* Fix expand to use new prev_line implementation
|
205
|
+
|
206
|
+
## [v0.5.0] - 2016-03-28
|
207
|
+
|
208
|
+
### Added
|
209
|
+
* Add ConfirmQuestion for #yes? & #no? calls
|
210
|
+
* Add ability to collect more than one answer through #collect call
|
211
|
+
* Add Choices#find_by for selecting choice based on attribute
|
212
|
+
* Add Prompt#expand for expanding key options
|
213
|
+
* Add :active_color, :help_color, :prefix options for customizing prompts display
|
214
|
+
|
215
|
+
### Changed
|
216
|
+
* Change Choice#from to allow for coersion of complex objects with keys
|
217
|
+
* Change Choices#pluck to search through object attributes
|
218
|
+
* Change #select :enum option help text to display actual numbers range
|
219
|
+
|
220
|
+
### Fixed
|
221
|
+
* Fix #no? to correctly ask negative question by @ondra-m
|
222
|
+
* Fix #ask :default option to handle nil or empty string
|
223
|
+
* Fix #multi_select :default option and color changing
|
224
|
+
|
225
|
+
## [v0.4.0] - 2016-02-08
|
226
|
+
|
227
|
+
### Added
|
228
|
+
* Add :enum option for #select & #multi_select to allow for numerical selection by @rtoshiro
|
229
|
+
* Add new key event types to KeyEvent
|
230
|
+
* Add #slider for picking values from range of numbers
|
231
|
+
* Add #enum_select for selecting option from enumerated list
|
232
|
+
* Add ability to configure error messages for #ask call
|
233
|
+
* Add new ConversionError type
|
234
|
+
|
235
|
+
### Changed
|
236
|
+
* Move #blank? to Utils
|
237
|
+
* Update pastel dependency
|
238
|
+
|
239
|
+
## [v0.3.0] - 2015-12-28
|
240
|
+
|
241
|
+
### Added
|
242
|
+
* Add prefix option to prompt to customize #ask, #select, #multi_select
|
243
|
+
* Add default printing to #ask
|
244
|
+
* Add #yes?/#no? boolean queries
|
245
|
+
* Add Evaluator and Result for validation checking to Question
|
246
|
+
* Add ability for #ask to display error messages on failed validation
|
247
|
+
* Add ability to specify in-built names for validation e.i. :email
|
248
|
+
* Add KeyEvent for keyboard events publishing to Reader
|
249
|
+
* Add #read_multiline to Reader
|
250
|
+
* Add :convert option for ask configuration
|
251
|
+
* Add ability to specify custom proc converters
|
252
|
+
* Add #ask_keypress to gather character input
|
253
|
+
* Add #ask_multiline to gather multiline input
|
254
|
+
* Add MaskedQuestion & #mask method for masking input stream characters
|
255
|
+
|
256
|
+
### Changed
|
257
|
+
* Change Reader#read_keypress to be robust and read correctly byte sequences
|
258
|
+
* Change Reader#getc to #read_line and extend arguments with echo option
|
259
|
+
* Extract cursor movement to dependency tty-cursor
|
260
|
+
* Change List & MultiList to subscribe to keyboard events
|
261
|
+
* Change to move mode inside reader namespace
|
262
|
+
* Remove Response & Error objects
|
263
|
+
* Remove :char option from #ask
|
264
|
+
* Change :read option to specify mode of reading out of :line, :multiline, :keypress
|
265
|
+
* Rename #confirm to #ok
|
266
|
+
|
267
|
+
## [v0.2.0] - 2015-11-23
|
268
|
+
|
269
|
+
### Added
|
270
|
+
* Add ability to select choice form list #select
|
271
|
+
* Add ability to select multiple options #multi_select
|
272
|
+
* Add :read option to #ask for reading specific type input
|
273
|
+
|
274
|
+
### Changed
|
275
|
+
* Change #ask api to be similar to #select and #multi_select behaviour
|
276
|
+
* Change #ask :argument option to be :required
|
277
|
+
* Remove :valid option from #ask as #select is a better solution
|
278
|
+
|
279
|
+
## [v0.1.0] - 2015-11-01
|
280
|
+
|
281
|
+
* Initial implementation and release
|
282
|
+
|
283
|
+
[v0.17.1]: https://github.com/piotrmurach/tty-prompt/compare/v0.17.0...v0.17.1
|
284
|
+
[v0.17.0]: https://github.com/piotrmurach/tty-prompt/compare/v0.16.1...v0.17.0
|
285
|
+
[v0.16.1]: https://github.com/piotrmurach/tty-prompt/compare/v0.16.0...v0.16.1
|
286
|
+
[v0.16.0]: https://github.com/piotrmurach/tty-prompt/compare/v0.15.0...v0.16.0
|
287
|
+
[v0.15.0]: https://github.com/piotrmurach/tty-prompt/compare/v0.14.0...v0.15.0
|
288
|
+
[v0.14.0]: https://github.com/piotrmurach/tty-prompt/compare/v0.13.2...v0.14.0
|
289
|
+
[v0.13.2]: https://github.com/piotrmurach/tty-prompt/compare/v0.13.1...v0.13.2
|
290
|
+
[v0.13.1]: https://github.com/piotrmurach/tty-prompt/compare/v0.13.0...v0.13.1
|
291
|
+
[v0.13.0]: https://github.com/piotrmurach/tty-prompt/compare/v0.12.0...v0.13.0
|
292
|
+
[v0.12.0]: https://github.com/piotrmurach/tty-prompt/compare/v0.11.0...v0.12.0
|
293
|
+
[v0.11.0]: https://github.com/piotrmurach/tty-prompt/compare/v0.10.1...v0.11.0
|
294
|
+
[v0.10.1]: https://github.com/piotrmurach/tty-prompt/compare/v0.10.0...v0.10.1
|
295
|
+
[v0.10.0]: https://github.com/piotrmurach/tty-prompt/compare/v0.9.0...v0.10.0
|
296
|
+
[v0.9.0]: https://github.com/piotrmurach/tty-prompt/compare/v0.8.0...v0.9.0
|
297
|
+
[v0.8.0]: https://github.com/piotrmurach/tty-prompt/compare/v0.7.1...v0.8.0
|
298
|
+
[v0.7.1]: https://github.com/piotrmurach/tty-prompt/compare/v0.7.0...v0.7.1
|
299
|
+
[v0.7.0]: https://github.com/piotrmurach/tty-prompt/compare/v0.6.0...v0.7.0
|
300
|
+
[v0.6.0]: https://github.com/piotrmurach/tty-prompt/compare/v0.5.0...v0.6.0
|
301
|
+
[v0.5.0]: https://github.com/piotrmurach/tty-prompt/compare/v0.4.0...v0.5.0
|
302
|
+
[v0.4.0]: https://github.com/piotrmurach/tty-prompt/compare/v0.3.0...v0.4.0
|
303
|
+
[v0.3.0]: https://github.com/piotrmurach/tty-prompt/compare/v0.2.0...v0.3.0
|
304
|
+
[v0.2.0]: https://github.com/piotrmurach/tty-prompt/compare/v0.1.0...v0.2.0
|
305
|
+
[v0.1.0]: https://github.com/piotrmurach/tty-prompt/compare/v0.1.0
|
data/README.md
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
<div align="center">
|
2
|
+
<a href="https://piotrmurach.github.io/tty" target="_blank"><img width="130" src="https://cdn.rawgit.com/piotrmurach/tty/master/images/tty.png" alt="tty logo" /></a>
|
3
|
+
</div>
|
4
|
+
|
1
5
|
# TTY::Prompt [][gitter]
|
2
6
|
|
3
7
|
[][gem]
|
data/lib/tty/prompt/list.rb
CHANGED
@@ -21,7 +21,7 @@ module TTY
|
|
21
21
|
PAGE_HELP = '(Move up or down to reveal more choices)'.freeze
|
22
22
|
|
23
23
|
# Allowed keys for filter, along with backspace and canc.
|
24
|
-
FILTER_KEYS_MATCHER = /\A\
|
24
|
+
FILTER_KEYS_MATCHER = /\A([[:alnum:]]|[[:punct:]])\Z/
|
25
25
|
|
26
26
|
# Create instance of TTY::Prompt::List menu.
|
27
27
|
#
|
@@ -50,7 +50,8 @@ module TTY
|
|
50
50
|
@help_color = options.fetch(:help_color) { @prompt.help_color }
|
51
51
|
@marker = options.fetch(:marker) { symbols[:pointer] }
|
52
52
|
@cycle = options.fetch(:cycle) { false }
|
53
|
-
@
|
53
|
+
@filterable = options.fetch(:filter) { false }
|
54
|
+
@filter = []
|
54
55
|
@help = options[:help]
|
55
56
|
@first_render = true
|
56
57
|
@done = false
|
@@ -121,7 +122,7 @@ module TTY
|
|
121
122
|
# Note that enumeration and filter are mutually exclusive
|
122
123
|
tokens = if enumerate?
|
123
124
|
[" or number (1-#{choices.size})", '']
|
124
|
-
elsif
|
125
|
+
elsif filterable?
|
125
126
|
['', ", and letter keys to filter"]
|
126
127
|
else
|
127
128
|
['', '']
|
@@ -157,12 +158,12 @@ module TTY
|
|
157
158
|
# @api public
|
158
159
|
def choices(values = (not_set = true))
|
159
160
|
if not_set
|
160
|
-
if @filter.
|
161
|
+
if !filterable? || @filter.empty?
|
161
162
|
@choices
|
162
163
|
else
|
163
164
|
@choices.select do |_choice|
|
164
165
|
!_choice.disabled? &&
|
165
|
-
_choice.name.downcase.include?(@filter.downcase)
|
166
|
+
_choice.name.downcase.include?(@filter.join.downcase)
|
166
167
|
end
|
167
168
|
end
|
168
169
|
else
|
@@ -241,25 +242,25 @@ module TTY
|
|
241
242
|
alias keytab keydown
|
242
243
|
|
243
244
|
def keypress(event)
|
244
|
-
return unless
|
245
|
+
return unless filterable?
|
245
246
|
|
246
247
|
if event.value =~ FILTER_KEYS_MATCHER
|
247
|
-
@filter
|
248
|
+
@filter << event.value
|
248
249
|
@active = 1
|
249
250
|
end
|
250
251
|
end
|
251
252
|
|
252
253
|
def keydelete(*)
|
253
|
-
return unless
|
254
|
+
return unless filterable?
|
254
255
|
|
255
|
-
@filter
|
256
|
+
@filter.clear
|
256
257
|
@active = 1
|
257
258
|
end
|
258
259
|
|
259
260
|
def keybackspace(*)
|
260
|
-
return unless
|
261
|
+
return unless filterable?
|
261
262
|
|
262
|
-
@filter.
|
263
|
+
@filter.pop
|
263
264
|
@active = 1
|
264
265
|
end
|
265
266
|
|
@@ -372,13 +373,22 @@ module TTY
|
|
372
373
|
header.join
|
373
374
|
end
|
374
375
|
|
376
|
+
# Is filtering enabled?
|
377
|
+
#
|
378
|
+
# @return [Boolean]
|
379
|
+
#
|
380
|
+
# @api private
|
381
|
+
def filterable?
|
382
|
+
@filterable
|
383
|
+
end
|
384
|
+
|
375
385
|
# Header part showing the current filter
|
376
386
|
#
|
377
387
|
# @return String
|
378
388
|
#
|
379
389
|
# @api private
|
380
390
|
def filter_help
|
381
|
-
"(Filter: #{@filter.inspect})"
|
391
|
+
"(Filter: #{@filter.join.inspect})"
|
382
392
|
end
|
383
393
|
|
384
394
|
# Render initial help and selected choice
|
@@ -392,7 +402,7 @@ module TTY
|
|
392
402
|
@prompt.decorate(selected_item, @active_color)
|
393
403
|
elsif @first_render
|
394
404
|
@prompt.decorate(help, @help_color)
|
395
|
-
elsif @filter.
|
405
|
+
elsif filterable? && @filter.any?
|
396
406
|
@prompt.decorate(filter_help, @help_color)
|
397
407
|
end
|
398
408
|
end
|
@@ -71,11 +71,11 @@ module TTY
|
|
71
71
|
if @done && @echo
|
72
72
|
@prompt.decorate(selected_names, @active_color)
|
73
73
|
elsif @selected.size.nonzero? && @echo
|
74
|
-
help_suffix = @filter.
|
74
|
+
help_suffix = filterable? && @filter.any? ? " #{filter_help}" : ""
|
75
75
|
selected_names + (@first_render ? " #{instructions}" : help_suffix)
|
76
76
|
elsif @first_render
|
77
77
|
instructions
|
78
|
-
elsif @filter.
|
78
|
+
elsif filterable? && @filter.any?
|
79
79
|
filter_help
|
80
80
|
end
|
81
81
|
end
|
data/lib/tty/prompt/version.rb
CHANGED
data/spec/unit/select_spec.rb
CHANGED
@@ -500,6 +500,25 @@ RSpec.describe TTY::Prompt, '#select' do
|
|
500
500
|
expect(actual_prompt_output).to eql(expected_prompt_output)
|
501
501
|
end
|
502
502
|
|
503
|
+
it "filters based on alphanumeric and punctuation characters" do
|
504
|
+
prompt = TTY::TestPrompt.new
|
505
|
+
prompt.input << "p" << "*" << "2" << "\r"
|
506
|
+
prompt.input.rewind
|
507
|
+
|
508
|
+
answer = prompt.select("What email?", %w(p*1@mail.com p*2@mail.com p*3@mail.com), filter: true)
|
509
|
+
expect(answer).to eql("p*2@mail.com")
|
510
|
+
|
511
|
+
actual_prompt_output = prompt.output.string
|
512
|
+
expected_prompt_output =
|
513
|
+
output_helper("What email?", %w(p*1@mail.com p*2@mail.com p*3@mail.com), "p*1@mail.com", init: true, hint: "Use arrow keys, press Enter to select, and letter keys to filter") +
|
514
|
+
output_helper("What email?", %w(p*1@mail.com p*2@mail.com p*3@mail.com), "p*1@mail.com", hint: 'Filter: "p"') +
|
515
|
+
output_helper("What email?", %w(p*1@mail.com p*2@mail.com p*3@mail.com), "p*1@mail.com", hint: 'Filter: "p*"') +
|
516
|
+
output_helper("What email?", %w(p*2@mail.com), "p*2@mail.com", hint: 'Filter: "p*2"') +
|
517
|
+
exit_message("What email?", "p*2@mail.com")
|
518
|
+
|
519
|
+
expect(actual_prompt_output).to eql(expected_prompt_output)
|
520
|
+
end
|
521
|
+
|
503
522
|
# This test can't be done in an exact way, at least, with the current framework
|
504
523
|
it "doesn't exit when there are no matching entries" do
|
505
524
|
prompt = TTY::TestPrompt.new
|
data/tty-prompt.gemspec
CHANGED
@@ -13,7 +13,9 @@ Gem::Specification.new do |spec|
|
|
13
13
|
spec.homepage = "https://piotrmurach.github.io/tty"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
16
|
-
spec.files = Dir[
|
16
|
+
spec.files = Dir['{lib,spec,examples}/**/*.rb']
|
17
|
+
spec.files += Dir['tasks/*', 'tty-prompt.gemspec']
|
18
|
+
spec.files += Dir['README.md', 'CHANGELOG.md', 'LICENSE.txt', 'Rakefile']
|
17
19
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
20
|
spec.test_files = Dir["spec/**/*.rb"]
|
19
21
|
spec.require_paths = ["lib"]
|
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.17.
|
4
|
+
version: 0.17.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Piotr Murach
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-10-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: necromancer
|
@@ -136,6 +136,7 @@ executables: []
|
|
136
136
|
extensions: []
|
137
137
|
extra_rdoc_files: []
|
138
138
|
files:
|
139
|
+
- CHANGELOG.md
|
139
140
|
- LICENSE.txt
|
140
141
|
- README.md
|
141
142
|
- Rakefile
|