prompts 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/lib/prompts/content.rb +1 -1
- data/lib/prompts/form.rb +18 -13
- data/lib/prompts/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3105477fb552d35423f55db2fd9dc67d0187e0ef02fc1ef6e7f1394405787c00
|
4
|
+
data.tar.gz: cb9a0a8a247e329fd75f3af7e01c38cbe57b0fdc9f3c584eb310527b6dd51e2b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d6d7e0a75213bbb99c10103b7069ff5be9e4e9113214d800ddc61567a90f4b6f5590c1c9e1cfbe003457d65827650b46ca149187c4fbad312bc5980a7c12c235
|
7
|
+
data.tar.gz: 3bbc31709a1eb187dd00b73f70bae8edf829360db4b6cc0a0b275ae01b9c188645b4559afb45fc05ff7232475cb55ebbd223b1f8fa9416175e2ff732029a2e97
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
|
3
|
+
## [0.3.1] - 2024-10-08
|
4
|
+
|
5
|
+
- Keep past frames in the terminal window ([@fractaledmind](https://github.com/fractaledmind/prompts/pull/10))
|
6
|
+
- Allow users to specify a new for form fields ([@fractaledmind](https://github.com/fractaledmind/prompts/pull/11))
|
7
|
+
|
3
8
|
## [0.3.0] - 2024-10-08
|
4
9
|
|
5
10
|
- Update `fmt` gem and use new syntax ([@KonnorRogers](https://github.com/fractaledmind/prompts/pull/9))
|
data/lib/prompts/content.rb
CHANGED
data/lib/prompts/form.rb
CHANGED
@@ -10,8 +10,9 @@ module Prompts
|
|
10
10
|
|
11
11
|
def initialize
|
12
12
|
@content = Prompts::Content.new
|
13
|
-
@
|
14
|
-
@
|
13
|
+
@index = 0
|
14
|
+
@prompts = {}
|
15
|
+
@results = {}
|
15
16
|
end
|
16
17
|
|
17
18
|
def content(&block)
|
@@ -19,37 +20,41 @@ module Prompts
|
|
19
20
|
@content
|
20
21
|
end
|
21
22
|
|
22
|
-
def text(label: nil, prompt: "> ", hint: nil, default: nil, required: false, validate: nil, &block)
|
23
|
+
def text(label: nil, prompt: "> ", hint: nil, default: nil, required: false, validate: nil, name: nil, &block)
|
23
24
|
prompt = TextPrompt.new(label: label, prompt: prompt, hint: hint, default: default, required: required, validate: validate)
|
24
25
|
yield(prompt) if block
|
25
26
|
prepend_form_content_to_prompt(prompt)
|
26
|
-
@
|
27
|
+
key = name || (@index += 1)
|
28
|
+
@prompts[key] = prompt
|
27
29
|
end
|
28
30
|
|
29
|
-
def select(label: nil, options: nil, prompt: "> ", hint: nil, default: nil, validate: nil, &block)
|
31
|
+
def select(label: nil, options: nil, prompt: "> ", hint: nil, default: nil, validate: nil, name: nil, &block)
|
30
32
|
prompt = SelectPrompt.new(label: label, options: options, prompt: prompt, hint: hint, default: default, validate: validate)
|
31
33
|
yield(prompt) if block
|
32
34
|
prepend_form_content_to_prompt(prompt)
|
33
|
-
@
|
35
|
+
key = name || (@index += 1)
|
36
|
+
@prompts[key] = prompt
|
34
37
|
end
|
35
38
|
|
36
|
-
def pause(label: nil, prompt: "> ", hint: nil, default: nil, required: false, validate: nil, &block)
|
39
|
+
def pause(label: nil, prompt: "> ", hint: nil, default: nil, required: false, validate: nil, name: nil, &block)
|
37
40
|
prompt = PausePrompt.new(label: label, prompt: prompt, hint: hint, default: default, required: required, validate: validate)
|
38
41
|
yield(prompt) if block
|
39
42
|
prepend_form_content_to_prompt(prompt)
|
40
|
-
@
|
43
|
+
key = name || (@index += 1)
|
44
|
+
@prompts[key] = prompt
|
41
45
|
end
|
42
46
|
|
43
|
-
def confirm(label: nil, prompt: "> ", hint: nil, default: nil, required: false, validate: nil, &block)
|
47
|
+
def confirm(label: nil, prompt: "> ", hint: nil, default: nil, required: false, validate: nil, name: nil, &block)
|
44
48
|
prompt = ConfirmPrompt.new(label: label, prompt: prompt, hint: hint, default: default, required: required, validate: validate)
|
45
49
|
yield(prompt) if block
|
46
50
|
prepend_form_content_to_prompt(prompt)
|
47
|
-
@
|
51
|
+
key = name || (@index += 1)
|
52
|
+
@prompts[key] = prompt
|
48
53
|
end
|
49
54
|
|
50
55
|
def submit
|
51
|
-
@prompts.each do |prompt|
|
52
|
-
@results
|
56
|
+
@prompts.each do |key, prompt|
|
57
|
+
@results[key] = prompt.ask
|
53
58
|
end
|
54
59
|
@results
|
55
60
|
end
|
@@ -58,7 +63,7 @@ module Prompts
|
|
58
63
|
|
59
64
|
def prepend_form_content_to_prompt(prompt)
|
60
65
|
prompt.prepare_content
|
61
|
-
|
66
|
+
prompt.prepend_content([SPACE])
|
62
67
|
prompt.prepend_content(*@content.slots)
|
63
68
|
end
|
64
69
|
end
|
data/lib/prompts/version.rb
CHANGED