kbsecret 1.5.0 → 1.6.0.pre.1
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/lib/kbsecret/cli/command/stash_edit.rb +63 -0
- data/lib/kbsecret/version.rb +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d384a16be43f8baa6578087b59c95246000b33d5b13754fceadfe16e6b77b3da
|
4
|
+
data.tar.gz: 0ff1842cefb7ccbd9d8c7f6e672c0770f60278b45d202211cf29073057335929
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 113ea5e98212ee6c2253c0e3481c17ff0691f24f3d61f2467351a37a8d3b315264b43fbef42112b72190f34e2e5bae094d4e27533095e5af3f2f9bab48581dc6
|
7
|
+
data.tar.gz: 473e111587d99f91c1cd1c230f31a14fad11d992b4f4b195f84bc3240fea39d633433fb3a07ac745f81b0fb49a9bc4d88f5607d183bc7549e99110ea3d384b47
|
@@ -0,0 +1,63 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "tempfile"
|
4
|
+
require "base64"
|
5
|
+
|
6
|
+
module KBSecret
|
7
|
+
class CLI
|
8
|
+
module Command
|
9
|
+
# The implementation of `kbsecret stash-edit`.
|
10
|
+
class StashEdit < Abstract
|
11
|
+
def initialize(argv)
|
12
|
+
super(argv) do |cli|
|
13
|
+
cli.slop do |o|
|
14
|
+
o.banner = <<~HELP
|
15
|
+
Usage:
|
16
|
+
kbsecret stash-edit [options] <record>
|
17
|
+
HELP
|
18
|
+
|
19
|
+
o.string "-s", "--session", "the session to search in", default: :default
|
20
|
+
o.bool "-b", "--base64", "base64 decode the file before editing, and encode it after"
|
21
|
+
end
|
22
|
+
|
23
|
+
cli.dreck do
|
24
|
+
string :label
|
25
|
+
end
|
26
|
+
|
27
|
+
cli.ensure_session!
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
# @see Command::Abstract#setup!
|
32
|
+
def setup!
|
33
|
+
@record = cli.session[cli.args[:label]]
|
34
|
+
end
|
35
|
+
|
36
|
+
# @see Command::Abstract#validate!
|
37
|
+
def validate!
|
38
|
+
cli.die "Missing $EDITOR." unless ENV["EDITOR"]
|
39
|
+
cli.die "No such unstructured record." unless @record && @record.type == :unstructured
|
40
|
+
end
|
41
|
+
|
42
|
+
# @see Command::Abstract#run!
|
43
|
+
def run!
|
44
|
+
tempfile = Tempfile.new(@record.label)
|
45
|
+
contents = cli.opts.base64? ? Base64.decode64(@record.text) : @record.text
|
46
|
+
|
47
|
+
tempfile.write(contents)
|
48
|
+
tempfile.flush
|
49
|
+
|
50
|
+
system "#{ENV["EDITOR"]} #{tempfile.path}"
|
51
|
+
|
52
|
+
tempfile.rewind
|
53
|
+
|
54
|
+
contents = cli.opts.base64? ? Base64.encode64(tempfile.read) : tempfile.read
|
55
|
+
@record.text = contents
|
56
|
+
ensure
|
57
|
+
tempfile.close
|
58
|
+
tempfile&.unlink
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
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.
|
4
|
+
version: 1.6.0.pre.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-04-
|
11
|
+
date: 2018-04-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|
@@ -229,6 +229,7 @@ files:
|
|
229
229
|
- lib/kbsecret/cli/command/rm.rb
|
230
230
|
- lib/kbsecret/cli/command/session.rb
|
231
231
|
- lib/kbsecret/cli/command/sessions.rb
|
232
|
+
- lib/kbsecret/cli/command/stash_edit.rb
|
232
233
|
- lib/kbsecret/cli/command/stash_file.rb
|
233
234
|
- lib/kbsecret/cli/command/todo.rb
|
234
235
|
- lib/kbsecret/cli/command/types.rb
|
@@ -260,9 +261,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
260
261
|
version: 2.3.0
|
261
262
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
262
263
|
requirements:
|
263
|
-
- - "
|
264
|
+
- - ">"
|
264
265
|
- !ruby/object:Gem::Version
|
265
|
-
version:
|
266
|
+
version: 1.3.1
|
266
267
|
requirements: []
|
267
268
|
rubyforge_project:
|
268
269
|
rubygems_version: 2.7.6
|