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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 85f88312acdfb5be0eb5b24924d140c96d01453f742edbc1a1576a8759c37997
4
- data.tar.gz: d82a75efffa864d9854a78c29a1f1ae110bbce7b61cd24770067ad1103c29c45
3
+ metadata.gz: 3105477fb552d35423f55db2fd9dc67d0187e0ef02fc1ef6e7f1394405787c00
4
+ data.tar.gz: cb9a0a8a247e329fd75f3af7e01c38cbe57b0fdc9f3c584eb310527b6dd51e2b
5
5
  SHA512:
6
- metadata.gz: ce5e838beb75e5d1e70fcfebcdc5eaf42e5dc77046465af025c2a8c9d78db70092f78a59737da631c12f89b9c292183cc80642c45f6b8b16036d54d5ad2bb83a
7
- data.tar.gz: 4223935ce6374fa970f1e5634666a413fad19980105bce0258952a8caab283046a3a3473203ce0439ff168a408d355cea025cca10abe1adaeb80cc4816b7115b
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))
@@ -64,7 +64,7 @@ module Prompts
64
64
  end
65
65
 
66
66
  def erase_down
67
- OUTPUT.print "\e[J"
67
+ OUTPUT.print "\e[2J\e[H"
68
68
  end
69
69
  end
70
70
  end
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
- @prompts = []
14
- @results = []
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
- @prompts << prompt
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
- @prompts << prompt
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
- @prompts << prompt
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
- @prompts << prompt
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 << prompt.ask
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
- @content.gap
66
+ prompt.prepend_content([SPACE])
62
67
  prompt.prepend_content(*@content.slots)
63
68
  end
64
69
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Prompts
4
- VERSION = "0.3.0"
4
+ VERSION = "0.3.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prompts
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen Margheim