mini_readline 0.6.4 → 0.6.5
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/README.md +36 -18
- data/lib/mini_readline.rb +2 -2
- data/lib/mini_readline/options.rb +3 -0
- data/lib/mini_readline/raw_term/windows.rb +1 -1
- data/lib/mini_readline/read_line/edit.rb +2 -2
- data/lib/mini_readline/version.rb +1 -1
- data/tests/mini_readline_tests.rb +16 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: de25a37c0b75ebcb2e6e8edbcc0e7bfb08aaa863
|
4
|
+
data.tar.gz: b842f03c9f0804b79ee9254bf7d623a06536e111
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8c9a5d664a358812295f1358f21c6857abd02204f94d9b0c317636da9d11a506c868e1822887774cf6bb88e8524986898d01d5af9258ddc51530872aacb71692
|
7
|
+
data.tar.gz: 294db641b431ea5a069441332405185cc89ae771ca74115d4dad71e88213f31d6508c41c9a65bebdf261d8d503742e73184ac622601c7845c45ccccb26e235cc
|
data/README.md
CHANGED
@@ -102,35 +102,46 @@ also be accomplished with the command:
|
|
102
102
|
|
103
103
|
### Compatible Mode
|
104
104
|
|
105
|
-
In
|
106
|
-
|
105
|
+
In compatible mode, mini_readline tries to be somewhat compatible with the
|
106
|
+
classic system readline facility. Here is this compatible mode in action with
|
107
|
+
entry history enabled:
|
107
108
|
|
108
109
|
```ruby
|
109
|
-
|
110
|
+
MiniReadline.readline('>', true)
|
110
111
|
```
|
111
|
-
|
112
|
-
|
112
|
+
and with entry history disabled:
|
113
113
|
```ruby
|
114
|
-
|
114
|
+
MiniReadline.readline('>', false)
|
115
115
|
```
|
116
116
|
Where the string argument is the prompt seen by the user and the flag controls
|
117
|
-
the history buffer.
|
118
|
-
|
119
|
-
|
117
|
+
the history buffer. Use true to enable history and false to disable it.
|
118
|
+
|
119
|
+
##### Extensions
|
120
|
+
|
121
|
+
In addition to the standard readline arguments, additional arguments may be
|
122
|
+
passed in to access additional features. This is done with an optional trailing
|
123
|
+
hash argument. For example, the following bit of compatibility mode code gets
|
124
|
+
a string with password hiding:
|
120
125
|
```ruby
|
121
|
-
MiniReadline.readline(
|
126
|
+
MiniReadline.readline(">", false, secret_mask: "*")
|
122
127
|
```
|
123
|
-
|
124
|
-
|
125
|
-
MiniReadline.readline('>', false)
|
126
|
-
```
|
127
|
-
While it does require some small changes, the latter form is the preferred one.
|
128
|
+
See the section Options below for more information on the sorts of things that
|
129
|
+
can be accomplished with these options settings.
|
128
130
|
|
129
131
|
##### Module Aliasing [Deprecated]
|
130
132
|
|
131
133
|
For enhanced compatibility, the mini_readline gem has the ability to alias
|
132
|
-
itself as the readline gem.
|
133
|
-
|
134
|
+
itself as the readline gem. When this feature is used, compatible code is even
|
135
|
+
more compatible looking:
|
136
|
+
```ruby
|
137
|
+
Readline.readline('>', true)
|
138
|
+
```
|
139
|
+
or to avoid tracking command history, use:
|
140
|
+
|
141
|
+
```ruby
|
142
|
+
Readline.readline('>', false)
|
143
|
+
```
|
144
|
+
The aliasing of modules is subject to the following list of conditions:
|
134
145
|
|
135
146
|
1) If the global variable $no_alias_read_line_module is set to true before the
|
136
147
|
mini_readline gem is required, *no* aliasing will take place.
|
@@ -259,6 +270,9 @@ BASE_OPTIONS = {
|
|
259
270
|
#string "*" to use stars or " "
|
260
271
|
#for invisible secrets.
|
261
272
|
|
273
|
+
:initial => "", #The initial text for the entry.
|
274
|
+
#An empty string for none.
|
275
|
+
|
262
276
|
:term => nil, #Filled in by raw_term.rb
|
263
277
|
#MiniReadline::RawTerm
|
264
278
|
|
@@ -288,7 +302,11 @@ eoi inputs are treated as unmapped. If enabled, they raise a MiniReadlineEOI
|
|
288
302
|
exception.
|
289
303
|
* :secret_mask is a masking character to be used for sensitive input like a
|
290
304
|
password or missile launch code. This should be exactly one character long.
|
291
|
-
Typical values are "
|
305
|
+
Typical values are "\*" or " ". Also, any secret entries should be done with
|
306
|
+
the history option **TURNED OFF**. Otherwise later entries will be able to
|
307
|
+
retrieve the secret codes by just scrolling through previous entries.
|
308
|
+
* :initial is the initial text used to prefill the readline edit area with the
|
309
|
+
specified text. Leave as an empty string to default to the empty edit area.
|
292
310
|
* :term is the interactive source of data, the console by default. The raw
|
293
311
|
terminal console driver automatically adapts to the system environment
|
294
312
|
(Windows or Other) so that correct operation is normally achieved with no
|
data/lib/mini_readline.rb
CHANGED
@@ -26,8 +26,8 @@ module MiniReadline
|
|
26
26
|
end
|
27
27
|
|
28
28
|
#The (limited) compatibility module function.
|
29
|
-
def self.readline(prompt = "", history = nil)
|
30
|
-
get_reader.readline(prompt: prompt, history: history)
|
29
|
+
def self.readline(prompt = "", history = nil, options = {})
|
30
|
+
get_reader.readline(options.merge({prompt: prompt, history: history}))
|
31
31
|
end
|
32
32
|
|
33
33
|
end
|
@@ -39,8 +39,8 @@ module MiniReadline
|
|
39
39
|
@options = options
|
40
40
|
@history = history
|
41
41
|
@term = @options[:term]
|
42
|
-
@
|
43
|
-
@
|
42
|
+
@edit_buffer = @options[:initial]
|
43
|
+
@edit_posn = @edit_buffer.length
|
44
44
|
@working = true
|
45
45
|
|
46
46
|
@edit_window = EditWindow.new(@options)
|
@@ -73,16 +73,29 @@ class MiniReadlineTester < Minitest::Test
|
|
73
73
|
assert_equal("quit", result)
|
74
74
|
end
|
75
75
|
|
76
|
+
def test_reading_with_a_default
|
77
|
+
puts
|
78
|
+
puts "To finish this test, enter the word: quit"
|
79
|
+
|
80
|
+
result = ''
|
81
|
+
|
82
|
+
loop do
|
83
|
+
result = MiniReadline.readline(">", false, initial: "qui").chomp
|
84
|
+
puts result.inspect
|
85
|
+
break unless result != "quit"
|
86
|
+
end
|
87
|
+
|
88
|
+
assert_equal("quit", result)
|
89
|
+
end
|
90
|
+
|
76
91
|
def test_reading_a_password
|
77
92
|
puts
|
78
93
|
puts "To finish this test, enter the word: password"
|
79
94
|
|
80
|
-
edit = MiniReadline::Readline.new
|
81
|
-
|
82
95
|
result = ''
|
83
96
|
|
84
97
|
loop do
|
85
|
-
result =
|
98
|
+
result = MiniReadline.readline(">", false, secret_mask: "*").chomp
|
86
99
|
puts result.inspect
|
87
100
|
break unless result != "password"
|
88
101
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mini_readline
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Camilleri
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-09-
|
11
|
+
date: 2016-09-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|