tty-prompt 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -5
- data/CHANGELOG.md +13 -0
- data/Gemfile +0 -1
- data/README.md +42 -25
- data/lib/tty-prompt.rb +0 -1
- data/lib/tty/prompt.rb +1 -1
- data/lib/tty/prompt/list.rb +0 -4
- data/lib/tty/prompt/reader.rb +32 -9
- data/lib/tty/prompt/reader/mode.rb +12 -36
- data/lib/tty/prompt/version.rb +1 -1
- data/spec/spec_helper.rb +0 -1
- data/spec/unit/converters/convert_file_spec.rb +5 -2
- data/spec/unit/converters/convert_path_spec.rb +5 -2
- data/spec/unit/keypress_spec.rb +10 -0
- data/spec/unit/reader/key_event_spec.rb +1 -1
- data/spec/unit/reader/read_keypress_spec.rb +54 -7
- data/tty-prompt.gemspec +1 -1
- metadata +36 -38
- data/lib/tty/prompt/reader/mode/echo.rb +0 -43
- data/lib/tty/prompt/reader/mode/raw.rb +0 -43
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 69404a2dc9ce5d0527ec0326e38f5a42efec6cea
|
4
|
+
data.tar.gz: 4a37238a51cdc8d3e5fe338ddfdfa52cfb5a5383
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d52270bb3e0c6ef868658f3ac3c255ac124588e8d830d21578c15655538fbdbeb5828af29608c62ba06342b239a84dcfb130d5821fbbf696b3f57181a0141215
|
7
|
+
data.tar.gz: 522ee9fcff9c80d548c2d043f9bfe3d3d1abeead54387dee9c3242c203a0804d9f4841da6a5bc888c66e6cf286f3db8346de55dc366706e14a63ae1a2e4302d3
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,17 @@
|
|
1
1
|
# Change log
|
2
2
|
|
3
|
+
## [v0.7.0] - 2016-07-17
|
4
|
+
|
5
|
+
### Added
|
6
|
+
* Add :interrupt_handler option to customise keyboard interrupt behaviour
|
7
|
+
|
8
|
+
### Changed
|
9
|
+
* Remove tty-platform dependency
|
10
|
+
|
11
|
+
### Fixed
|
12
|
+
* Fix Reader#read_keypress issue when handling interrupt signal by Ondrej Moravcik(@ondra-m)
|
13
|
+
* Fix raw & echo modes to use standard library support by Kim Burgestrand(@Burgestrand)
|
14
|
+
|
3
15
|
## [v0.6.0] - 2016-05-21
|
4
16
|
|
5
17
|
### Changed
|
@@ -86,6 +98,7 @@
|
|
86
98
|
|
87
99
|
* Initial implementation and release
|
88
100
|
|
101
|
+
[v0.7.0]: https://github.com/piotrmurach/tty-prompt/compare/v0.6.0...v0.7.0
|
89
102
|
[v0.6.0]: https://github.com/piotrmurach/tty-prompt/compare/v0.5.0...v0.6.0
|
90
103
|
[v0.5.0]: https://github.com/piotrmurach/tty-prompt/compare/v0.4.0...v0.5.0
|
91
104
|
[v0.4.0]: https://github.com/piotrmurach/tty-prompt/compare/v0.3.0...v0.4.0
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -55,21 +55,23 @@ Or install it yourself as:
|
|
55
55
|
* [2.2.9 prefix](#229-prefix)
|
56
56
|
* [2.2.10 active_color](#2210-active_color)
|
57
57
|
* [2.2.11 help_color](#2211-help_color)
|
58
|
+
* [2.2.12 interrupt](#2212-interrupt)
|
58
59
|
* [2.3 keypress](#23-keypress)
|
59
60
|
* [2.4 multiline](#24-multiline)
|
60
61
|
* [2.5 mask](#25-mask)
|
61
62
|
* [2.6 yes?/no?](#26-yesno)
|
62
63
|
* [2.7 select](#27-select)
|
63
|
-
|
64
|
-
|
65
|
-
* [2.
|
66
|
-
* [2.
|
67
|
-
* [2.
|
68
|
-
* [2.
|
69
|
-
* [2.
|
70
|
-
|
71
|
-
|
72
|
-
|
64
|
+
* [2.7.1 multi_select](#271-multi_select)
|
65
|
+
* [2.7.2 enum_select](#272-enum_select)
|
66
|
+
* [2.8 expand](#28-expand)
|
67
|
+
* [2.9 collect](#29-collect)
|
68
|
+
* [2.10 suggest](#210-suggest)
|
69
|
+
* [2.11 slider](#211-slider)
|
70
|
+
* [2.12 say](#212-say)
|
71
|
+
* [2.12.1 ok](#2121-ok)
|
72
|
+
* [2.12.2 warn](#2122-warn)
|
73
|
+
* [2.12.3 error](#2123-error)
|
74
|
+
|
73
75
|
|
74
76
|
## 1. Usage
|
75
77
|
|
@@ -320,7 +322,7 @@ The **TTY::Prompt** comes with bult-in validations for `:email` and you can use
|
|
320
322
|
prompt.ask('What is your email?') { |q| q.validate :email }
|
321
323
|
```
|
322
324
|
|
323
|
-
|
325
|
+
#### 2.2.8 messages
|
324
326
|
|
325
327
|
By default `tty-prompt` comes with predefined error messages for `required`, `in`, `validate` options. You can change these and configure to your liking either by inling them with the option:
|
326
328
|
|
@@ -339,7 +341,7 @@ prompt.ask('What is your email?') do |q|
|
|
339
341
|
end
|
340
342
|
```
|
341
343
|
|
342
|
-
|
344
|
+
#### 2.2.9 prefix
|
343
345
|
|
344
346
|
You can prefix each question asked using the `:prefix` option. This option can be applied either globally for all prompts or individual for each one:
|
345
347
|
|
@@ -347,7 +349,7 @@ You can prefix each question asked using the `:prefix` option. This option can b
|
|
347
349
|
prompt = TTY::Prompt.new(prefix: '[?] ')
|
348
350
|
```
|
349
351
|
|
350
|
-
|
352
|
+
#### 2.2.10 active_color
|
351
353
|
|
352
354
|
All prompt types support `:active_color` option. In case of `select`, `multi_select`, `enum_select` or `expand` this color is used to highlight the currently selected choice. All the resulted inputs provided by user that are read in by the prompt as answer are highlighted with this color. This option can be applied either globablly for all prompts or individually.
|
353
355
|
|
@@ -355,9 +357,9 @@ All prompt types support `:active_color` option. In case of `select`, `multi_sel
|
|
355
357
|
prompt.select('What size?', %w(Large Medium Small), active_color: :cyan)
|
356
358
|
```
|
357
359
|
|
358
|
-
Please
|
360
|
+
Please [see pastel](https://github.com/piotrmurach/pastel#3-supported-colors) for all supported colors.
|
359
361
|
|
360
|
-
|
362
|
+
#### 2.2.11 help_color
|
361
363
|
|
362
364
|
Prompts such as `select`, `multi_select`, `expand` support `:help_color` which is used to customize the help text. This option can be applied either globablly for all prompts or individually.
|
363
365
|
|
@@ -365,6 +367,21 @@ Prompts such as `select`, `multi_select`, `expand` support `:help_color` which i
|
|
365
367
|
prompt.select('What size?', %w(Large Medium Small), help_color: :cyan)
|
366
368
|
```
|
367
369
|
|
370
|
+
#### 2.2.12 interrupt
|
371
|
+
|
372
|
+
By default `InputInterrupt` error will be raised when the user hits the interrupt key(Control-C). However, you can customise this behaviour by passing the `:interrupt` option. The available options are:
|
373
|
+
|
374
|
+
* `:signal` - sends interrupt signal
|
375
|
+
* `:exit` - exists with status code
|
376
|
+
* `:noop` - skips handler
|
377
|
+
* custom proc
|
378
|
+
|
379
|
+
For example, to send interrupt signal do:
|
380
|
+
|
381
|
+
```ruby
|
382
|
+
prompt = TTY::Prompt.new(interrupt: :signal)
|
383
|
+
```
|
384
|
+
|
368
385
|
### 2.3 keypress
|
369
386
|
|
370
387
|
In order to ask question with a single character or keypress answer use `keypress`:
|
@@ -558,7 +575,7 @@ prompt.select("Choose your destiny?", choices, help: "(Bash keyboard)", marker:
|
|
558
575
|
# Jax
|
559
576
|
```
|
560
577
|
|
561
|
-
### 2.
|
578
|
+
### 2.7.1 multi_select
|
562
579
|
|
563
580
|
For asking questions involving multiple selection list use `multi_select` method by passing the question and possible choices:
|
564
581
|
|
@@ -659,7 +676,7 @@ prompt.select("Select drinks?", choices, help: 'Press beer can against keyboard'
|
|
659
676
|
# ⬡ bourbon
|
660
677
|
```
|
661
678
|
|
662
|
-
### 2.
|
679
|
+
### 2.7.2 enum_select
|
663
680
|
|
664
681
|
In order to ask for standard selection from indexed list you can use `enum_select` and pass question together with possible choices:
|
665
682
|
|
@@ -718,7 +735,7 @@ end
|
|
718
735
|
# Select an editor? /usr/bin/vim
|
719
736
|
```
|
720
737
|
|
721
|
-
### 2.
|
738
|
+
### 2.8 expand
|
722
739
|
|
723
740
|
The `expand` provides a compact way to ask a question with many options.
|
724
741
|
|
@@ -782,7 +799,7 @@ If user types `h` and presses enter, an expanded view will be shown which furthe
|
|
782
799
|
|
783
800
|
Run `examples/expand.rb` to see the prompt in action.
|
784
801
|
|
785
|
-
### 2.
|
802
|
+
### 2.9 collect
|
786
803
|
|
787
804
|
In order to collect more than one answer use `collect` method. Using the `key` you can describe the answers key name. All the methods for asking user input such as `ask`, `mask`, `select` can be directly invoked on the key. The key composition is very flexible by allowing nested keys. If you want the value to be automatically converted to required type use [convert](#221-convert).
|
788
805
|
|
@@ -804,7 +821,7 @@ end
|
|
804
821
|
# {:name => "Piotr", :age => 30, :address => {:street => "Street", :city => "City", :zip => "123"}}
|
805
822
|
```
|
806
823
|
|
807
|
-
### 2.
|
824
|
+
### 2.10 suggest
|
808
825
|
|
809
826
|
To suggest possible matches for the user input use `suggest` method like so:
|
810
827
|
|
@@ -826,7 +843,7 @@ prompt.suggest('b', possible, indent: 4, single_text: 'Perhaps you meant?')
|
|
826
843
|
# blame
|
827
844
|
```
|
828
845
|
|
829
|
-
### 2.
|
846
|
+
### 2.11 slider
|
830
847
|
|
831
848
|
If you have constrained range of numbers for user to choose from you may consider using `slider`. The slider provides easy visual way of picking a value marked by `O` marker.
|
832
849
|
|
@@ -853,7 +870,7 @@ end
|
|
853
870
|
# |--O-------| 4
|
854
871
|
```
|
855
872
|
|
856
|
-
### 2.
|
873
|
+
### 2.12 say
|
857
874
|
|
858
875
|
To simply print message out to stdout use `say` like so:
|
859
876
|
|
@@ -865,7 +882,7 @@ The `say` method also accepts option `:color` which supports all the colors prov
|
|
865
882
|
|
866
883
|
**TTY::Prompt** provides more specific versions of `say` method to better express intenation behind the message such as `ok`, `warn` and `error`.
|
867
884
|
|
868
|
-
|
885
|
+
#### 2.12.1 ok
|
869
886
|
|
870
887
|
Print message(s) in green do:
|
871
888
|
|
@@ -873,7 +890,7 @@ Print message(s) in green do:
|
|
873
890
|
prompt.ok(...)
|
874
891
|
```
|
875
892
|
|
876
|
-
|
893
|
+
#### 2.12.2 warn
|
877
894
|
|
878
895
|
Print message(s) in yellow do:
|
879
896
|
|
@@ -881,7 +898,7 @@ Print message(s) in yellow do:
|
|
881
898
|
prompt.warn(...)
|
882
899
|
```
|
883
900
|
|
884
|
-
|
901
|
+
#### 2.12.3 error
|
885
902
|
|
886
903
|
Print message(s) in red do:
|
887
904
|
|
data/lib/tty-prompt.rb
CHANGED
data/lib/tty/prompt.rb
CHANGED
data/lib/tty/prompt/list.rb
CHANGED
data/lib/tty/prompt/reader.rb
CHANGED
@@ -14,6 +14,10 @@ module TTY
|
|
14
14
|
# @api private
|
15
15
|
class Reader
|
16
16
|
include Wisper::Publisher
|
17
|
+
# Raised when the user hits the interrupt key(Control-C)
|
18
|
+
#
|
19
|
+
# @api public
|
20
|
+
InputInterrupt = Class.new(StandardError)
|
17
21
|
|
18
22
|
attr_reader :mode
|
19
23
|
|
@@ -22,20 +26,21 @@ module TTY
|
|
22
26
|
attr_reader :output
|
23
27
|
|
24
28
|
# Key input constants for decimal codes
|
25
|
-
CARRIAGE_RETURN = 13
|
26
|
-
NEWLINE = 10
|
27
|
-
BACKSPACE = 127
|
28
|
-
DELETE = 8
|
29
|
+
CARRIAGE_RETURN = 13
|
30
|
+
NEWLINE = 10
|
31
|
+
BACKSPACE = 127
|
32
|
+
DELETE = 8
|
29
33
|
|
30
34
|
CSI = "\e[".freeze
|
31
35
|
|
32
36
|
# Initialize a Reader
|
33
37
|
#
|
34
38
|
# @api public
|
35
|
-
def initialize(input, output)
|
36
|
-
@input
|
37
|
-
@output
|
38
|
-
@mode
|
39
|
+
def initialize(input, output, options = {})
|
40
|
+
@input = input
|
41
|
+
@output = output
|
42
|
+
@mode = Mode.new
|
43
|
+
@interrupt = options.fetch(:interrupt) { :error }
|
39
44
|
end
|
40
45
|
|
41
46
|
# Get input in unbuffered mode.
|
@@ -72,7 +77,7 @@ module TTY
|
|
72
77
|
mode.raw(true) do
|
73
78
|
key = read_char
|
74
79
|
emit_key_event(key) if key
|
75
|
-
|
80
|
+
handle_interrupt if key == Codes::CTRL_C
|
76
81
|
key
|
77
82
|
end
|
78
83
|
end
|
@@ -179,6 +184,24 @@ module TTY
|
|
179
184
|
line << char
|
180
185
|
end
|
181
186
|
end
|
187
|
+
|
188
|
+
# Handle input interrupt based on provided value
|
189
|
+
#
|
190
|
+
# @api private
|
191
|
+
def handle_interrupt
|
192
|
+
case @interrupt
|
193
|
+
when :signal
|
194
|
+
Process.kill('SIGINT', Process.pid)
|
195
|
+
when :exit
|
196
|
+
exit(130)
|
197
|
+
when Proc
|
198
|
+
@interrupt.call
|
199
|
+
when :noop
|
200
|
+
return
|
201
|
+
else
|
202
|
+
raise InputInterrupt
|
203
|
+
end
|
204
|
+
end
|
182
205
|
end # Reader
|
183
206
|
end # Prompt
|
184
207
|
end # TTY
|
@@ -1,8 +1,5 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
require 'tty/prompt/reader/mode/echo'
|
4
|
-
require 'tty/prompt/reader/mode/raw'
|
5
|
-
|
6
3
|
module TTY
|
7
4
|
class Prompt
|
8
5
|
class Reader
|
@@ -10,23 +7,8 @@ module TTY
|
|
10
7
|
# Initialize a Terminal
|
11
8
|
#
|
12
9
|
# @api public
|
13
|
-
def initialize(
|
14
|
-
@
|
15
|
-
@raw = Raw.new
|
16
|
-
end
|
17
|
-
|
18
|
-
# Switch echo on
|
19
|
-
#
|
20
|
-
# @api public
|
21
|
-
def echo_on
|
22
|
-
@echo.on
|
23
|
-
end
|
24
|
-
|
25
|
-
# Switch echo off
|
26
|
-
#
|
27
|
-
# @api public
|
28
|
-
def echo_off
|
29
|
-
@echo.off
|
10
|
+
def initialize(input = $stdin)
|
11
|
+
@input = input
|
30
12
|
end
|
31
13
|
|
32
14
|
# Echo given block
|
@@ -35,21 +17,11 @@ module TTY
|
|
35
17
|
#
|
36
18
|
# @api public
|
37
19
|
def echo(is_on = true, &block)
|
38
|
-
@
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
# @api public
|
44
|
-
def raw_on
|
45
|
-
@raw.on
|
46
|
-
end
|
47
|
-
|
48
|
-
# Switch raw mode off
|
49
|
-
#
|
50
|
-
# @api public
|
51
|
-
def raw_off
|
52
|
-
@raw.off
|
20
|
+
previous = @input.echo?
|
21
|
+
@input.echo = is_on
|
22
|
+
yield
|
23
|
+
ensure
|
24
|
+
@input.echo = previous
|
53
25
|
end
|
54
26
|
|
55
27
|
# Use raw mode in the given block
|
@@ -58,7 +30,11 @@ module TTY
|
|
58
30
|
#
|
59
31
|
# @api public
|
60
32
|
def raw(is_on = true, &block)
|
61
|
-
|
33
|
+
if is_on
|
34
|
+
@input.raw(&block)
|
35
|
+
else
|
36
|
+
yield
|
37
|
+
end
|
62
38
|
end
|
63
39
|
end # Mode
|
64
40
|
end # Reader
|
data/lib/tty/prompt/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -3,12 +3,15 @@
|
|
3
3
|
RSpec.describe TTY::Prompt::Question, 'convert file' do
|
4
4
|
it "converts to file" do
|
5
5
|
file = double(:file)
|
6
|
-
allow(File).to receive(:open).with(/test\.txt/).and_return(file)
|
7
6
|
prompt = TTY::TestPrompt.new
|
8
7
|
prompt.input << "test.txt"
|
9
8
|
prompt.input.rewind
|
9
|
+
|
10
|
+
allow(File).to receive(:open).with(/test\.txt/).and_return(file)
|
11
|
+
expect(File).to receive(:open).with(/test\.txt/)
|
12
|
+
|
10
13
|
answer = prompt.ask("Which file to open?", convert: :file)
|
14
|
+
|
11
15
|
expect(answer).to eq(file)
|
12
|
-
expect(File).to have_received(:open).with(/test\.txt/)
|
13
16
|
end
|
14
17
|
end
|
@@ -5,11 +5,14 @@ RSpec.describe TTY::Prompt::Question, 'convert path' do
|
|
5
5
|
|
6
6
|
it "converts pathname" do
|
7
7
|
path = double(:path)
|
8
|
-
allow(Pathname).to receive(:new).and_return(path)
|
9
8
|
prompt.input << "/path/to/file"
|
10
9
|
prompt.input.rewind
|
10
|
+
|
11
|
+
allow(Pathname).to receive(:new).and_return(path)
|
12
|
+
expect(Pathname).to receive(:new).with(/path\/to\/file/)
|
13
|
+
|
11
14
|
answer = prompt.ask('File location?', convert: :path)
|
15
|
+
|
12
16
|
expect(answer).to eql(path)
|
13
|
-
expect(Pathname).to have_received(:new).with(/path\/to\/file/)
|
14
17
|
end
|
15
18
|
end
|
data/spec/unit/keypress_spec.rb
CHANGED
@@ -16,4 +16,14 @@ RSpec.describe TTY::Prompt::Question, 'ask keypress' do
|
|
16
16
|
answer = prompt.keypress("Which one do you prefer a, b, c or d?")
|
17
17
|
expect(answer).to eq("a")
|
18
18
|
end
|
19
|
+
|
20
|
+
it "interrupts input" do
|
21
|
+
prompt = TTY::TestPrompt.new(interrupt: :exit)
|
22
|
+
prompt.input << "\x03"
|
23
|
+
prompt.input.rewind
|
24
|
+
|
25
|
+
expect {
|
26
|
+
prompt.keypress("Which one do you prefer a, b, c or d?")
|
27
|
+
}.to raise_error(SystemExit)
|
28
|
+
end
|
19
29
|
end
|
@@ -2,21 +2,68 @@
|
|
2
2
|
|
3
3
|
RSpec.describe TTY::Prompt::Reader, '#read_keypress' do
|
4
4
|
let(:input) { StringIO.new }
|
5
|
-
let(:out)
|
6
|
-
let(:reader) { described_class.new(input, out) }
|
5
|
+
let(:out) { StringIO.new }
|
7
6
|
|
8
7
|
it "reads single key press" do
|
8
|
+
reader = described_class.new(input, out)
|
9
9
|
input << "\e[Aaaaaaa\n"
|
10
10
|
input.rewind
|
11
|
+
|
11
12
|
answer = reader.read_keypress
|
13
|
+
|
12
14
|
expect(answer).to eq("\e[A")
|
13
15
|
end
|
14
16
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
17
|
+
context 'when Ctrl+C pressed' do
|
18
|
+
it "defaults to raising InputInterrupt" do
|
19
|
+
reader = described_class.new(input, out)
|
20
|
+
input << "\x03"
|
21
|
+
input.rewind
|
22
|
+
|
23
|
+
expect {
|
24
|
+
reader.read_keypress
|
25
|
+
}.to raise_error(TTY::Prompt::Reader::InputInterrupt)
|
26
|
+
end
|
27
|
+
|
28
|
+
it "sends interrupt signal when :signal option is chosen" do
|
29
|
+
reader = described_class.new(input, out, interrupt: :signal)
|
30
|
+
input << "\x03"
|
31
|
+
input.rewind
|
32
|
+
|
33
|
+
allow(Process).to receive(:pid).and_return(666)
|
34
|
+
allow(Process).to receive(:kill)
|
35
|
+
expect(Process).to receive(:kill).with('SIGINT', 666)
|
36
|
+
|
19
37
|
reader.read_keypress
|
20
|
-
|
38
|
+
end
|
39
|
+
|
40
|
+
it "exits with 130 code when :exit option is chosen" do
|
41
|
+
reader = described_class.new(input, out, interrupt: :exit)
|
42
|
+
input << "\x03"
|
43
|
+
input.rewind
|
44
|
+
|
45
|
+
expect {
|
46
|
+
reader.read_keypress
|
47
|
+
}.to raise_error(SystemExit)
|
48
|
+
end
|
49
|
+
|
50
|
+
it "evaluates custom handler when proc object is provided" do
|
51
|
+
handler = proc { raise ArgumentError }
|
52
|
+
reader = described_class.new(input, out, interrupt: handler)
|
53
|
+
input << "\x03"
|
54
|
+
input.rewind
|
55
|
+
|
56
|
+
expect {
|
57
|
+
reader.read_keypress
|
58
|
+
}.to raise_error(ArgumentError)
|
59
|
+
end
|
60
|
+
|
61
|
+
it "skips handler when handler is nil" do
|
62
|
+
reader = described_class.new(input, out, interrupt: :noop)
|
63
|
+
input << "\x03"
|
64
|
+
input.rewind
|
65
|
+
|
66
|
+
expect(reader.read_keypress).to eq("\x03")
|
67
|
+
end
|
21
68
|
end
|
22
69
|
end
|
data/tty-prompt.gemspec
CHANGED
@@ -21,9 +21,9 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.add_dependency 'necromancer', '~> 0.3.0'
|
22
22
|
spec.add_dependency 'pastel', '~> 0.6.0'
|
23
23
|
spec.add_dependency 'tty-cursor', '~> 0.3.0'
|
24
|
-
spec.add_dependency 'tty-platform', '~> 0.1.0'
|
25
24
|
spec.add_dependency 'wisper', '~> 1.6.1'
|
26
25
|
|
27
26
|
spec.add_development_dependency 'bundler', '>= 1.5.0', '< 2.0'
|
28
27
|
spec.add_development_dependency 'rake'
|
28
|
+
spec.add_development_dependency 'rspec', '~> 3.5.0'
|
29
29
|
end
|
metadata
CHANGED
@@ -1,119 +1,119 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tty-prompt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Piotr Murach
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-07-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: necromancer
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 0.3.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 0.3.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: pastel
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - ~>
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: 0.6.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - ~>
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 0.6.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: tty-cursor
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - ~>
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: 0.3.0
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - ~>
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 0.3.0
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: tty-platform
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - ~>
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: 0.1.0
|
62
|
-
type: :runtime
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - ~>
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: 0.1.0
|
69
55
|
- !ruby/object:Gem::Dependency
|
70
56
|
name: wisper
|
71
57
|
requirement: !ruby/object:Gem::Requirement
|
72
58
|
requirements:
|
73
|
-
- - ~>
|
59
|
+
- - "~>"
|
74
60
|
- !ruby/object:Gem::Version
|
75
61
|
version: 1.6.1
|
76
62
|
type: :runtime
|
77
63
|
prerelease: false
|
78
64
|
version_requirements: !ruby/object:Gem::Requirement
|
79
65
|
requirements:
|
80
|
-
- - ~>
|
66
|
+
- - "~>"
|
81
67
|
- !ruby/object:Gem::Version
|
82
68
|
version: 1.6.1
|
83
69
|
- !ruby/object:Gem::Dependency
|
84
70
|
name: bundler
|
85
71
|
requirement: !ruby/object:Gem::Requirement
|
86
72
|
requirements:
|
87
|
-
- -
|
73
|
+
- - ">="
|
88
74
|
- !ruby/object:Gem::Version
|
89
75
|
version: 1.5.0
|
90
|
-
- - <
|
76
|
+
- - "<"
|
91
77
|
- !ruby/object:Gem::Version
|
92
78
|
version: '2.0'
|
93
79
|
type: :development
|
94
80
|
prerelease: false
|
95
81
|
version_requirements: !ruby/object:Gem::Requirement
|
96
82
|
requirements:
|
97
|
-
- -
|
83
|
+
- - ">="
|
98
84
|
- !ruby/object:Gem::Version
|
99
85
|
version: 1.5.0
|
100
|
-
- - <
|
86
|
+
- - "<"
|
101
87
|
- !ruby/object:Gem::Version
|
102
88
|
version: '2.0'
|
103
89
|
- !ruby/object:Gem::Dependency
|
104
90
|
name: rake
|
105
91
|
requirement: !ruby/object:Gem::Requirement
|
106
92
|
requirements:
|
107
|
-
- -
|
93
|
+
- - ">="
|
108
94
|
- !ruby/object:Gem::Version
|
109
95
|
version: '0'
|
110
96
|
type: :development
|
111
97
|
prerelease: false
|
112
98
|
version_requirements: !ruby/object:Gem::Requirement
|
113
99
|
requirements:
|
114
|
-
- -
|
100
|
+
- - ">="
|
115
101
|
- !ruby/object:Gem::Version
|
116
102
|
version: '0'
|
103
|
+
- !ruby/object:Gem::Dependency
|
104
|
+
name: rspec
|
105
|
+
requirement: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - "~>"
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: 3.5.0
|
110
|
+
type: :development
|
111
|
+
prerelease: false
|
112
|
+
version_requirements: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - "~>"
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: 3.5.0
|
117
117
|
description: A beautiful and powerful interactive command line prompt with a robust
|
118
118
|
API for getting and validating complex inputs.
|
119
119
|
email:
|
@@ -122,9 +122,9 @@ executables: []
|
|
122
122
|
extensions: []
|
123
123
|
extra_rdoc_files: []
|
124
124
|
files:
|
125
|
-
- .gitignore
|
126
|
-
- .rspec
|
127
|
-
- .travis.yml
|
125
|
+
- ".gitignore"
|
126
|
+
- ".rspec"
|
127
|
+
- ".travis.yml"
|
128
128
|
- CHANGELOG.md
|
129
129
|
- CODE_OF_CONDUCT.md
|
130
130
|
- Gemfile
|
@@ -170,8 +170,6 @@ files:
|
|
170
170
|
- lib/tty/prompt/reader/codes.rb
|
171
171
|
- lib/tty/prompt/reader/key_event.rb
|
172
172
|
- lib/tty/prompt/reader/mode.rb
|
173
|
-
- lib/tty/prompt/reader/mode/echo.rb
|
174
|
-
- lib/tty/prompt/reader/mode/raw.rb
|
175
173
|
- lib/tty/prompt/result.rb
|
176
174
|
- lib/tty/prompt/slider.rb
|
177
175
|
- lib/tty/prompt/statement.rb
|
@@ -251,17 +249,17 @@ require_paths:
|
|
251
249
|
- lib
|
252
250
|
required_ruby_version: !ruby/object:Gem::Requirement
|
253
251
|
requirements:
|
254
|
-
- -
|
252
|
+
- - ">="
|
255
253
|
- !ruby/object:Gem::Version
|
256
254
|
version: '0'
|
257
255
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
258
256
|
requirements:
|
259
|
-
- -
|
257
|
+
- - ">="
|
260
258
|
- !ruby/object:Gem::Version
|
261
259
|
version: '0'
|
262
260
|
requirements: []
|
263
261
|
rubyforge_project:
|
264
|
-
rubygems_version: 2.
|
262
|
+
rubygems_version: 2.5.1
|
265
263
|
signing_key:
|
266
264
|
specification_version: 4
|
267
265
|
summary: A beautiful and powerful interactive command line prompt.
|
@@ -1,43 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
module TTY
|
4
|
-
class Prompt
|
5
|
-
class Reader
|
6
|
-
class Mode
|
7
|
-
# A class responsible for toggling echo.
|
8
|
-
class Echo
|
9
|
-
# Turn echo on
|
10
|
-
#
|
11
|
-
# @api public
|
12
|
-
def on
|
13
|
-
%x{stty echo} if TTY::Platform.unix?
|
14
|
-
end
|
15
|
-
|
16
|
-
# Turn echo off
|
17
|
-
#
|
18
|
-
# @api public
|
19
|
-
def off
|
20
|
-
%x{stty -echo} if TTY::Platform.unix?
|
21
|
-
end
|
22
|
-
|
23
|
-
# Wrap code block inside echo
|
24
|
-
#
|
25
|
-
# @api public
|
26
|
-
def echo(is_on=true, &block)
|
27
|
-
value = nil
|
28
|
-
off unless is_on
|
29
|
-
value = block.call if block_given?
|
30
|
-
rescue NoMethodError, Interrupt => error
|
31
|
-
puts "#{error.class} #{error.message}"
|
32
|
-
puts error.backtrace
|
33
|
-
on
|
34
|
-
exit
|
35
|
-
ensure
|
36
|
-
on
|
37
|
-
value
|
38
|
-
end
|
39
|
-
end # Echo
|
40
|
-
end # Mode
|
41
|
-
end # Reader
|
42
|
-
end # Prompt
|
43
|
-
end # TTY
|
@@ -1,43 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
module TTY
|
4
|
-
class Prompt
|
5
|
-
class Reader
|
6
|
-
class Mode
|
7
|
-
# A class responsible for toggling raw mode.
|
8
|
-
class Raw
|
9
|
-
# Turn raw mode on
|
10
|
-
#
|
11
|
-
# @api public
|
12
|
-
def on
|
13
|
-
%x{stty raw} if TTY::Platform.unix?
|
14
|
-
end
|
15
|
-
|
16
|
-
# Turn raw mode off
|
17
|
-
#
|
18
|
-
# @api public
|
19
|
-
def off
|
20
|
-
%x{stty -raw} if TTY::Platform.unix?
|
21
|
-
end
|
22
|
-
|
23
|
-
# Wrap code block inside raw mode
|
24
|
-
#
|
25
|
-
# @api public
|
26
|
-
def raw(is_on=true, &block)
|
27
|
-
value = nil
|
28
|
-
on if is_on
|
29
|
-
value = block.call if block_given?
|
30
|
-
rescue NoMethodError, Interrupt => error
|
31
|
-
puts "#{error.class} #{error.message}"
|
32
|
-
puts error.backtrace
|
33
|
-
off
|
34
|
-
exit
|
35
|
-
ensure
|
36
|
-
off
|
37
|
-
value
|
38
|
-
end
|
39
|
-
end # Raw
|
40
|
-
end # Mode
|
41
|
-
end # Reader
|
42
|
-
end # Prompt
|
43
|
-
end # TTY
|