kbsecret 1.7.0 → 1.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/kbsecret/cli/command/new.rb +1 -2
- data/lib/kbsecret/cli.rb +23 -0
- data/lib/kbsecret/version.rb +1 -1
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4ff3ce4b84d20568268d1bdc3562e53d879d9bf43aab3a4dd02e230d90e78c55
|
4
|
+
data.tar.gz: 2377ec56804df5e5540eb844ccf4817b3d24f49340c88a085a4d16797d9bfdc8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1b04426b4e02c57329ce063bf8fa8268174e613d155c7f0903711d3fd4e4ad4c8b450ec19cd745090f9ee91fc771739cca97897da703bf6191d1dbaf4bc0a1de
|
7
|
+
data.tar.gz: a7143a0f3c43c859db26909bb0701ef8caf2ebe025642f829e006249e70ec48359ebf13137d507b1d9aad3b6f1e02931fa4227407d4a77681e7ca2a608f59574
|
@@ -60,13 +60,12 @@ module KBSecret
|
|
60
60
|
fields = if cli.opts.terse?
|
61
61
|
CLI.stdin.read.chomp.split cli.opts[:ifs]
|
62
62
|
else
|
63
|
-
prompt = TTY::Prompt.new
|
64
63
|
klass = Record.class_for(@type)
|
65
64
|
klass.external_fields.map do |field|
|
66
65
|
if cli.opts.generate? && klass.sensitive?(field)
|
67
66
|
generator.secret
|
68
67
|
else
|
69
|
-
prompt
|
68
|
+
cli.prompt "#{field.capitalize}?",
|
70
69
|
echo: !klass.sensitive?(field) || cli.opts.echo?
|
71
70
|
end
|
72
71
|
end
|
data/lib/kbsecret/cli.rb
CHANGED
@@ -6,6 +6,7 @@ require "slop"
|
|
6
6
|
require "dreck"
|
7
7
|
require "abbrev"
|
8
8
|
require "pastel"
|
9
|
+
require "termios"
|
9
10
|
|
10
11
|
module KBSecret
|
11
12
|
# An encapsulation of useful methods for kbsecret's CLI.
|
@@ -155,6 +156,28 @@ module KBSecret
|
|
155
156
|
die "#{e.to_s.capitalize}."
|
156
157
|
end
|
157
158
|
|
159
|
+
# Prompt the user for some input.
|
160
|
+
# @param question [String] the question to ask the user
|
161
|
+
# @param echo [Boolean] whether or not to echo the user's input
|
162
|
+
# @return [String] the user's response, with trailing newline removed
|
163
|
+
def prompt(question, echo: true)
|
164
|
+
if self.class.stdin.tty?
|
165
|
+
old_attrs = Termios.tcgetattr(self.class.stdin)
|
166
|
+
new_attrs = old_attrs.dup
|
167
|
+
new_attrs.lflag &= ~Termios::ECHO unless echo
|
168
|
+
Termios.tcsetattr(self.class.stdin, Termios::TCSANOW, new_attrs)
|
169
|
+
end
|
170
|
+
|
171
|
+
self.class.stdout.print "#{question} "
|
172
|
+
response = self.class.stdin.gets.chomp
|
173
|
+
response
|
174
|
+
ensure
|
175
|
+
if self.class.stdin.tty?
|
176
|
+
self.class.stdout.puts unless echo
|
177
|
+
Termios.tcsetattr(self.class.stdin, Termios::TCSANOW, old_attrs)
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
158
181
|
# Print an informational message.
|
159
182
|
# @param msg [String] the message to print
|
160
183
|
# @return [void]
|
data/lib/kbsecret/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kbsecret
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.7.
|
4
|
+
version: 1.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- William Woodruff
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-05-
|
11
|
+
date: 2018-05-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|
@@ -170,6 +170,20 @@ dependencies:
|
|
170
170
|
- - "~>"
|
171
171
|
- !ruby/object:Gem::Version
|
172
172
|
version: '0.7'
|
173
|
+
- !ruby/object:Gem::Dependency
|
174
|
+
name: ruby-termios
|
175
|
+
requirement: !ruby/object:Gem::Requirement
|
176
|
+
requirements:
|
177
|
+
- - "~>"
|
178
|
+
- !ruby/object:Gem::Version
|
179
|
+
version: '1.0'
|
180
|
+
type: :runtime
|
181
|
+
prerelease: false
|
182
|
+
version_requirements: !ruby/object:Gem::Requirement
|
183
|
+
requirements:
|
184
|
+
- - "~>"
|
185
|
+
- !ruby/object:Gem::Version
|
186
|
+
version: '1.0'
|
173
187
|
- !ruby/object:Gem::Dependency
|
174
188
|
name: slop
|
175
189
|
requirement: !ruby/object:Gem::Requirement
|