prompts 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/prompts/box.rb +3 -3
- data/lib/prompts/form.rb +6 -6
- data/lib/prompts/prompt.rb +5 -5
- data/lib/prompts/select_prompt.rb +1 -1
- data/lib/prompts/version.rb +1 -1
- data/lib/prompts.rb +1 -3
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 85f88312acdfb5be0eb5b24924d140c96d01453f742edbc1a1576a8759c37997
|
4
|
+
data.tar.gz: d82a75efffa864d9854a78c29a1f1ae110bbce7b61cd24770067ad1103c29c45
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ce5e838beb75e5d1e70fcfebcdc5eaf42e5dc77046465af025c2a8c9d78db70092f78a59737da631c12f89b9c292183cc80642c45f6b8b16036d54d5ad2bb83a
|
7
|
+
data.tar.gz: 4223935ce6374fa970f1e5634666a413fad19980105bce0258952a8caab283046a3a3473203ce0439ff168a408d355cea025cca10abe1adaeb80cc4816b7115b
|
data/CHANGELOG.md
CHANGED
data/lib/prompts/box.rb
CHANGED
@@ -55,16 +55,16 @@ module Prompts
|
|
55
55
|
|
56
56
|
def top_border
|
57
57
|
border = @border_parts[:top_left] + @border_parts[:horizontal] * (@width - 2) + @border_parts[:top_right]
|
58
|
-
Fmt("#{@line_padding}%{border}
|
58
|
+
Fmt("#{@line_padding}%{border}|>#{@border_color}", border: border)
|
59
59
|
end
|
60
60
|
|
61
61
|
def bottom_border
|
62
62
|
border = @border_parts[:bottom_left] + @border_parts[:horizontal] * (@width - 2) + @border_parts[:bottom_right]
|
63
|
-
Fmt("#{@line_padding}%{border}
|
63
|
+
Fmt("#{@line_padding}%{border}|>#{@border_color}", border: border)
|
64
64
|
end
|
65
65
|
|
66
66
|
def align(text, alignment, between: @border_parts[:vertical])
|
67
|
-
formatted_boundary = Fmt("%{boundary}
|
67
|
+
formatted_boundary = Fmt("%{boundary}|>#{@border_color}", boundary: between)
|
68
68
|
wrap_text(text, width: @width, line_prefix: formatted_boundary + SPACE, line_suffix: SPACE + formatted_boundary, alignment: alignment)
|
69
69
|
end
|
70
70
|
end
|
data/lib/prompts/form.rb
CHANGED
@@ -3,8 +3,8 @@
|
|
3
3
|
module Prompts
|
4
4
|
class Form
|
5
5
|
def self.submit(&block)
|
6
|
-
instance = new
|
7
|
-
yield instance if
|
6
|
+
instance = new
|
7
|
+
yield instance if block
|
8
8
|
instance.submit
|
9
9
|
end
|
10
10
|
|
@@ -21,28 +21,28 @@ module Prompts
|
|
21
21
|
|
22
22
|
def text(label: nil, prompt: "> ", hint: nil, default: nil, required: false, validate: nil, &block)
|
23
23
|
prompt = TextPrompt.new(label: label, prompt: prompt, hint: hint, default: default, required: required, validate: validate)
|
24
|
-
yield(prompt) if
|
24
|
+
yield(prompt) if block
|
25
25
|
prepend_form_content_to_prompt(prompt)
|
26
26
|
@prompts << prompt
|
27
27
|
end
|
28
28
|
|
29
29
|
def select(label: nil, options: nil, prompt: "> ", hint: nil, default: nil, validate: nil, &block)
|
30
30
|
prompt = SelectPrompt.new(label: label, options: options, prompt: prompt, hint: hint, default: default, validate: validate)
|
31
|
-
yield(prompt) if
|
31
|
+
yield(prompt) if block
|
32
32
|
prepend_form_content_to_prompt(prompt)
|
33
33
|
@prompts << prompt
|
34
34
|
end
|
35
35
|
|
36
36
|
def pause(label: nil, prompt: "> ", hint: nil, default: nil, required: false, validate: nil, &block)
|
37
37
|
prompt = PausePrompt.new(label: label, prompt: prompt, hint: hint, default: default, required: required, validate: validate)
|
38
|
-
yield(prompt) if
|
38
|
+
yield(prompt) if block
|
39
39
|
prepend_form_content_to_prompt(prompt)
|
40
40
|
@prompts << prompt
|
41
41
|
end
|
42
42
|
|
43
43
|
def confirm(label: nil, prompt: "> ", hint: nil, default: nil, required: false, validate: nil, &block)
|
44
44
|
prompt = ConfirmPrompt.new(label: label, prompt: prompt, hint: hint, default: default, required: required, validate: validate)
|
45
|
-
yield(prompt) if
|
45
|
+
yield(prompt) if block
|
46
46
|
prepend_form_content_to_prompt(prompt)
|
47
47
|
@prompts << prompt
|
48
48
|
end
|
data/lib/prompts/prompt.rb
CHANGED
@@ -61,7 +61,7 @@ module Prompts
|
|
61
61
|
|
62
62
|
if (@error = ensure_validity(response))
|
63
63
|
@content.reset!
|
64
|
-
@content.paragraph Fmt("%{error}red
|
64
|
+
@content.paragraph Fmt("%{error}|>red|>bold", error: @error + " Try again (×#{@attempts})...")
|
65
65
|
@attempts += 1
|
66
66
|
next
|
67
67
|
else
|
@@ -114,20 +114,20 @@ module Prompts
|
|
114
114
|
|
115
115
|
def formatted_prompt
|
116
116
|
prompt_with_space = @prompt.end_with?(SPACE) ? @prompt : @prompt + SPACE
|
117
|
-
ansi_prompt = Fmt("%{prompt}faint
|
117
|
+
ansi_prompt = Fmt("%{prompt}|>faint|>bold", prompt: prompt_with_space)
|
118
118
|
@formatted_prompt ||= Paragraph.new(ansi_prompt, width: MAX_WIDTH).lines
|
119
119
|
end
|
120
120
|
|
121
121
|
def formatted_label
|
122
|
-
Fmt("%{label}cyan
|
122
|
+
Fmt("%{label}|>cyan|>bold %{instructions}|>faint|>italic", label: @label, instructions: @instructions ? "(#{@instructions})" : "")
|
123
123
|
end
|
124
124
|
|
125
125
|
def formatted_hint
|
126
|
-
Fmt("%{hint}faint
|
126
|
+
Fmt("%{hint}|>faint|>bold", hint: @hint)
|
127
127
|
end
|
128
128
|
|
129
129
|
def formatted_error
|
130
|
-
Fmt("%{error}red
|
130
|
+
Fmt("%{error}|>red|>bold", error: @error + " Try again (×#{@attempts})...")
|
131
131
|
end
|
132
132
|
|
133
133
|
def ensure_validity(response)
|
@@ -29,7 +29,7 @@ module Prompts
|
|
29
29
|
def prepare_content
|
30
30
|
super
|
31
31
|
@options.each_with_index do |(key, value), index|
|
32
|
-
@content.paragraph Fmt("%{prefix}faint
|
32
|
+
@content.paragraph Fmt("%{prefix}|>faint|>bold %{option}", prefix: "#{index + 1}.", option: value)
|
33
33
|
end
|
34
34
|
@content
|
35
35
|
end
|
data/lib/prompts/version.rb
CHANGED
data/lib/prompts.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: prompts
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stephen Margheim
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-08
|
11
|
+
date: 2024-10-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: unicode-display_width
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 0.3.0
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: 0.3.0
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rainbow
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -128,7 +128,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
128
128
|
- !ruby/object:Gem::Version
|
129
129
|
version: '0'
|
130
130
|
requirements: []
|
131
|
-
rubygems_version: 3.5.
|
131
|
+
rubygems_version: 3.5.11
|
132
132
|
signing_key:
|
133
133
|
specification_version: 4
|
134
134
|
summary: Beautiful and user-friendly forms for your command-line Ruby applications.
|