tty-prompt 0.21.0 → 0.22.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/CHANGELOG.md +37 -1
- data/README.md +372 -215
- data/lib/tty-prompt.rb +1 -2
- data/lib/tty/prompt.rb +145 -142
- data/lib/tty/prompt/answers_collector.rb +2 -2
- data/lib/tty/prompt/block_paginator.rb +1 -1
- data/lib/tty/prompt/choice.rb +1 -1
- data/lib/tty/prompt/choices.rb +28 -11
- data/lib/tty/prompt/confirm_question.rb +23 -12
- data/lib/tty/prompt/const.rb +17 -0
- data/lib/tty/prompt/converter_dsl.rb +6 -7
- data/lib/tty/prompt/converter_registry.rb +31 -26
- data/lib/tty/prompt/converters.rb +139 -32
- data/lib/tty/prompt/enum_list.rb +27 -19
- data/lib/tty/prompt/errors.rb +31 -0
- data/lib/tty/prompt/evaluator.rb +1 -1
- data/lib/tty/prompt/expander.rb +20 -12
- data/lib/tty/prompt/keypress.rb +3 -3
- data/lib/tty/prompt/list.rb +57 -25
- data/lib/tty/prompt/mask_question.rb +2 -2
- data/lib/tty/prompt/multi_list.rb +71 -27
- data/lib/tty/prompt/multiline.rb +6 -5
- data/lib/tty/prompt/paginator.rb +1 -1
- data/lib/tty/prompt/question.rb +56 -31
- data/lib/tty/prompt/question/checks.rb +18 -0
- data/lib/tty/prompt/selected_choices.rb +76 -0
- data/lib/tty/prompt/slider.rb +67 -8
- data/lib/tty/prompt/statement.rb +3 -3
- data/lib/tty/prompt/suggestion.rb +5 -5
- data/lib/tty/prompt/symbols.rb +58 -58
- data/lib/tty/prompt/test.rb +36 -0
- data/lib/tty/prompt/utils.rb +1 -3
- data/lib/tty/prompt/version.rb +1 -1
- metadata +12 -24
- data/lib/tty/prompt/messages.rb +0 -49
- data/lib/tty/test_prompt.rb +0 -20
data/lib/tty/prompt/messages.rb
DELETED
@@ -1,49 +0,0 @@
|
|
1
|
-
module TTY
|
2
|
-
class Prompt
|
3
|
-
class Messages
|
4
|
-
|
5
|
-
def setup_messages
|
6
|
-
@messages = {
|
7
|
-
range?: 'Value %{value} must be within the range %{in}',
|
8
|
-
valid?: 'Your answer is invalid (must match %{valid})',
|
9
|
-
required?: 'Value must be provided'
|
10
|
-
}
|
11
|
-
end
|
12
|
-
|
13
|
-
def initialize
|
14
|
-
setup_messages
|
15
|
-
end
|
16
|
-
|
17
|
-
# Stores all the error messages displayed to user
|
18
|
-
# The currently supported messages are:
|
19
|
-
# * :range?
|
20
|
-
# * :required?
|
21
|
-
# * :valid?
|
22
|
-
attr_reader :messages
|
23
|
-
|
24
|
-
def get(key)
|
25
|
-
|
26
|
-
end
|
27
|
-
|
28
|
-
# Retrieve message based on the key
|
29
|
-
#
|
30
|
-
# @param [Symbol] name
|
31
|
-
# the name of message key
|
32
|
-
#
|
33
|
-
# @param [Hash] tokens
|
34
|
-
# the tokens to evaluate
|
35
|
-
#
|
36
|
-
# @return [Array[String]]
|
37
|
-
#
|
38
|
-
# @api private
|
39
|
-
def message_for(name, tokens = nil)
|
40
|
-
template = @messages[name]
|
41
|
-
if !template.match(/\%\{/).nil?
|
42
|
-
[template % tokens]
|
43
|
-
else
|
44
|
-
[template]
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
data/lib/tty/test_prompt.rb
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative 'prompt'
|
4
|
-
|
5
|
-
module TTY
|
6
|
-
# Used for initializing test cases
|
7
|
-
class TestPrompt < Prompt
|
8
|
-
def initialize(options = {})
|
9
|
-
@input = StringIO.new
|
10
|
-
@output = StringIO.new
|
11
|
-
options.merge!({
|
12
|
-
input: @input,
|
13
|
-
output: @output,
|
14
|
-
env: { "TTY_TEST" => true },
|
15
|
-
enable_color: options.fetch(:enable_color) { true }
|
16
|
-
})
|
17
|
-
super(options)
|
18
|
-
end
|
19
|
-
end # TestPrompt
|
20
|
-
end # TTY
|