kbsecret 0.6.0 → 0.6.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
  SHA1:
3
- metadata.gz: 04bf388d61371a29a5f721a4a39a03037fbd674c
4
- data.tar.gz: 4bc34dd530c79ecb34816c0013a36c47ecb969e4
3
+ metadata.gz: 78a85052182c04cc8a63759dfe1ffebcab9febf1
4
+ data.tar.gz: 57cf4570ac91c7ef25a3533f7ac1750d7b1dd510
5
5
  SHA512:
6
- metadata.gz: 6933f6c00c8ced6ebec24956790109f0238324e69194637fe7cabbb8be7cdac21e5de9732eba3c043f8cbc92d93def83195682013c1d019aca497423a04ff44a
7
- data.tar.gz: 3fbd02c35aaf1531b0365e7475ab3047c6b07ac442bd83f195d656b613fae4d1a3f8e4d450ce1d770312c59a61fc4518f4e3e084f60ac425c0105ce02f071ed4
6
+ metadata.gz: 4f98b14697eae67ab73822f4629793da398087003d701f74b123415a5f20cdf666919a886ef599564505bd5fe49f46f767dcd6656ca851f5351ecaa3356a74e3
7
+ data.tar.gz: 02ceed6620e31589f595ef39fdd50bb669739845d1ef1fb5c74a7e0f4c0b68e760d554207db59aaf2468b49ce936929955e420de1703b84c5605ee9da7eb59d4
@@ -29,7 +29,7 @@ KBSECRET_HELP = <<~EOS
29
29
  Available commands:
30
30
  #{ALL_CMDS.join(", ")}
31
31
 
32
- More more information about a particular command, try:
32
+ For more information about a particular command, try:
33
33
  kbsecret help <command>
34
34
  EOS
35
35
 
@@ -8,10 +8,8 @@ include KBSecret
8
8
  cmd = CLI.new do
9
9
  slop do |o|
10
10
  o.banner = <<~EOS
11
- Dump all fields for the given record.
12
-
13
11
  Usage:
14
- kbsecret dump-fields [--session <session>] <record>
12
+ kbsecret dump-fields [options] <record>
15
13
  EOS
16
14
 
17
15
  o.string "-s", "--session", "the session to search in", default: :default
@@ -8,14 +8,8 @@ include KBSecret
8
8
  cmd = CLI.new do
9
9
  slop do |o|
10
10
  o.banner = <<~EOS
11
- Retrieve environment records in a source-able format.
12
-
13
11
  Usage:
14
- kbsecret env [--session <session>] [--all] <record [record ...]>
15
-
16
- Examples:
17
- kbsecret env --all
18
- kbsecret env staging beta
12
+ kbsecret env [options] <record [record ...]>
19
13
  EOS
20
14
 
21
15
  o.string "-s", "--session", "the session to search in", default: :default
@@ -8,10 +8,8 @@ include KBSecret
8
8
  cmd = CLI.new do
9
9
  slop do |o|
10
10
  o.banner = <<~EOS
11
- List all secrets known to the specified session (or the default session).
12
-
13
11
  Usage:
14
- kbsecret list [--session <session>] [--show-all]
12
+ kbsecret list [options]
15
13
  EOS
16
14
 
17
15
  o.string "-s", "--session", "the session to list from", default: :default
@@ -8,14 +8,8 @@ include KBSecret
8
8
  cmd = CLI.new do
9
9
  slop do |o|
10
10
  o.banner = <<~EOS
11
- Retrieve login records.
12
-
13
11
  Usage:
14
- kbsecret login [--session <session>] <record [record ...]>
15
-
16
- Examples:
17
- kbsecret login --terse --ifs "*" gmail
18
- kbsecret login gmail netflix
12
+ kbsecret login [options] <record [record ...]>
19
13
  EOS
20
14
 
21
15
  o.string "-s", "--session", "the session to search in", default: :default
@@ -13,15 +13,9 @@ TYPE_ALIASES = Abbrev.abbrev(Record.record_types).freeze
13
13
  cmd = CLI.new do
14
14
  slop do |o|
15
15
  o.banner = <<~EOS
16
- Create a new secret record.
17
-
18
16
  Usage:
19
17
  kbsecret new [options] <type> <label>
20
18
  kbsecret new [options] --args <type> <label> <fields>
21
-
22
- Examples:
23
- kbsecret new login gmail
24
- kbsecret new environment foo-api
25
19
  EOS
26
20
 
27
21
  o.string "-s", "--session", "the session to contain the record", default: :default
@@ -9,18 +9,13 @@ include KBSecret
9
9
  cmd = CLI.new do
10
10
  slop do |o|
11
11
  o.banner = <<~EOS
12
- Create a new session.
13
-
14
12
  Usage:
15
- kbsecret new-session --label <label> --users <user1,...> --root <dir>
16
-
17
- Example:
18
- kbsecret new-session -l dev -u me,otherperson -r devsecrets
13
+ kbsecret new-session [options] --label <label> --root <dir>
19
14
  EOS
20
15
 
21
- o.string "-l", "--label", "the session label", default: :default
16
+ o.string "-l", "--label", "the session label"
22
17
  o.array "-u", "--users", "the keybase users", default: [Keybase.current_user]
23
- o.string "-r", "--root", "the secret root directory", default: "kbsecret"
18
+ o.string "-r", "--root", "the secret root directory"
24
19
  o.bool "-f", "--force", "force creation (ignore overwrites, etc.)"
25
20
  end
26
21
  end
@@ -9,14 +9,8 @@ include KBSecret
9
9
  cmd = CLI.new do
10
10
  slop do |o|
11
11
  o.banner = <<~EOS
12
- Retrieve a login record's password.
13
-
14
12
  Usage:
15
- kbsecret pass [--session <session>] [--clipboard] <record>
16
-
17
- Examples:
18
- kbsecret pass gmail | xclip
19
- kbsecret pass --clipboard gmail
13
+ kbsecret pass [options] <record>
20
14
  EOS
21
15
 
22
16
  o.string "-s", "--session", "the session to search in", default: :default
@@ -8,13 +8,8 @@ include KBSecret
8
8
  cmd = CLI.new do
9
9
  slop do |o|
10
10
  o.banner = <<~EOS
11
- Edit the raw JSON of a record in $EDITOR.
12
-
13
11
  Usage:
14
- kbsecret raw-edit [--session <session>] <record>
15
-
16
- Examples:
17
- kbsecret raw-edit gmail
12
+ kbsecret raw-edit [options] <record>
18
13
  EOS
19
14
 
20
15
  o.string "-s", "--session", "the session to search in", default: :default
@@ -11,10 +11,8 @@ $VERBOSE = nil # tty-prompt blasts us with irrelevant warnings on 2.4
11
11
  cmd = CLI.new do
12
12
  slop do |o|
13
13
  o.banner = <<~EOS
14
- Delete a record.
15
-
16
14
  Usage:
17
- kbsecret rm [--session <session>] [--interactive] <record>
15
+ kbsecret rm [options] <record>
18
16
  EOS
19
17
 
20
18
  o.string "-s", "--session", "the session containing the record", default: :default
@@ -8,14 +8,8 @@ include KBSecret
8
8
  cmd = CLI.new do
9
9
  slop do |o|
10
10
  o.banner = <<~EOS
11
- Deconfigure (and optionally delete) a session.
12
-
13
11
  Usage:
14
- kbsecret rm-session [--delete] <session>
15
-
16
- Example:
17
- kbsecret rm-session old-keys
18
- kbsecret rm-session --delete even-older-keys
12
+ kbsecret rm-session [options] <session>
19
13
  EOS
20
14
 
21
15
  o.bool "-d", "--delete", "unlink the session in addition to deconfiguration"
@@ -8,11 +8,8 @@ include KBSecret
8
8
  cmd = CLI.new do
9
9
  slop do |o|
10
10
  o.banner = <<~EOS
11
- List all available sessions.
12
- The sessions listed can be passed to other commands via the -s flag.
13
-
14
11
  Usage:
15
- kbsecret sessions [--show-all]
12
+ kbsecret sessions [options]
16
13
  EOS
17
14
 
18
15
  o.bool "-a", "--show-all", "show each session in depth (i.e. metadata)"
@@ -8,14 +8,8 @@ include KBSecret
8
8
  cmd = CLI.new do
9
9
  slop do |o|
10
10
  o.banner = <<~EOS
11
- Stash the given file (or stdin) as an unstructured record.
12
-
13
11
  Usage:
14
12
  kbsecret stash-file <record> [file]
15
-
16
- Example:
17
- kbsecret stash-file foo ~/foo
18
- echo "using stdin" | kbsecret stash-file from-stdin
19
13
  EOS
20
14
 
21
15
  o.string "-s", "--session", "the session to add to", default: :default
@@ -8,15 +8,8 @@ include KBSecret
8
8
  cmd = CLI.new do
9
9
  slop cmds: %w[start suspend complete] do |o|
10
10
  o.banner = <<~EOS
11
- Manage 'to do' records.
12
-
13
11
  Usage:
14
12
  kbsecret todo <start|suspend|complete> <record>
15
-
16
- Examples:
17
- kbsecret todo start unit-tests
18
- kbsecret todo suspend laundry
19
- kbsecret todo complete shopping
20
13
  EOS
21
14
 
22
15
  o.string "-s", "--session", "the session to search in", default: :default
@@ -36,25 +36,30 @@ module KBSecret
36
36
  @args = nil
37
37
  instance_eval(&block)
38
38
  rescue => e
39
- self.class.die e.to_s.capitalize
39
+ self.class.die "#{e.to_s.capitalize}."
40
40
  end
41
41
 
42
42
  # Parse options for a kbsecret utility, adding some default options for
43
- # introspection and help output.
43
+ # introspection, verbosity, and help output.
44
44
  # @param cmds [Array<String>] additional commands to print in `--introspect-flags`
45
45
  # @param errors [Boolean] whether or not to produce Slop errors
46
46
  # @return [Slop::Result] the result of argument parsing
47
47
  # @note This should be called within the block passed to {#initialize}.
48
- def slop(cmds: [], errors: false)
48
+ def slop(cmds: [], errors: true)
49
49
  @opts = Slop.parse suppress_errors: !errors do |o|
50
+ o.separator "Options:"
51
+
50
52
  yield o
51
53
 
52
- o.on "-h", "--help" do
54
+ o.bool "-V", "--verbose", "produce more verbose output"
55
+ o.bool "-w", "--no-warn", "suppress warning messages"
56
+
57
+ o.on "-h", "--help", "show this help message" do
53
58
  puts o
54
59
  exit
55
60
  end
56
61
 
57
- o.on "--introspect-flags" do
62
+ o.on "--introspect-flags", "dump recognized flags and subcommands" do
58
63
  comp = o.options.flat_map(&:flags) + cmds
59
64
  puts comp.join "\n"
60
65
  exit
@@ -86,7 +91,32 @@ module KBSecret
86
91
  # options or arguments are being tested for a valid session.
87
92
  def ensure_session!(where = :option)
88
93
  label = where == :option ? @opts[:session] : @args[:session]
89
- raise "Unknown session: '#{label}'." unless Config.session? label
94
+ raise "Unknown session: '#{label}'" unless Config.session? label
95
+ end
96
+
97
+ # Print an informational message if verbose output has been enabled.
98
+ # @param msg [String] the message to print
99
+ # @return [void]
100
+ def info(msg)
101
+ return unless @opts.verbose?
102
+ STDERR.puts "#{"Info".green}: #{msg}"
103
+ end
104
+
105
+ # Print a warning message unless warnings have been suppressed.
106
+ # @param msg [String] the message to print
107
+ # @return [void]
108
+ def warn(msg)
109
+ return if @opts.no_warn?
110
+ STDERR.puts "#{"Warning".yellow}: #{msg}"
111
+ end
112
+
113
+ # Print an error message and terminate.
114
+ # @param msg [String] the message to print
115
+ # @return [void]
116
+ # @note This method does not return!
117
+ def die(msg)
118
+ pretty = "#{"Fatal".red}: #{msg}"
119
+ abort pretty
90
120
  end
91
121
 
92
122
  class << self
@@ -94,51 +124,18 @@ module KBSecret
94
124
  # @param msg [String] the message to print
95
125
  # @return [void]
96
126
  # @note This method does not return!
127
+ # @deprecated use {#die} instead.
97
128
  def die(msg)
98
129
  pretty = "#{"Fatal".red}: #{msg}"
99
130
  abort pretty
100
131
  end
101
132
 
102
- # Instantiate a session if it exists, and terminate otherwise.
103
- # @param sess_label [String, Symbol] the session label to instantiate
104
- # @return [void]
105
- # @note This method does not return if the given session is not configured!
106
- # @deprecated Use {#ensure_session!} instead.
107
- def ensure_session(sess_label)
108
- die "Unknown session: '#{sess_label}'." unless Config.session? sess_label
109
-
110
- Session.new label: sess_label
111
- end
112
-
113
133
  # Finds a reasonable default field separator by checking the environment first
114
134
  # and then falling back to ":".
115
135
  # @return [String] the field separator
116
136
  def ifs
117
137
  ENV["IFS"] || ":"
118
138
  end
119
-
120
- # Parse arguments for a kbsecret utility, adding some default options for
121
- # introspection and help output.
122
- # @param cmds [Array<String>] additional commands to print in `--introspect-flags`
123
- # @param errors [Boolean] whether or not to produce Slop errors
124
- # @return [Slop::Result] the result of argument parsing
125
- # @deprecated Use {#initialize} instead.
126
- def slop(cmds: [], errors: false)
127
- Slop.parse suppress_errors: !errors do |o|
128
- yield o
129
-
130
- o.on "-h", "--help" do
131
- puts o
132
- exit
133
- end
134
-
135
- o.on "--introspect-flags" do
136
- comp = o.options.flat_map(&:flags) + cmds
137
- puts comp.join "\n"
138
- exit
139
- end
140
- end
141
- end
142
139
  end
143
140
  end
144
141
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module KBSecret
2
4
  module Record
3
5
  # Represents a record containing a 'to do' item and its status.
@@ -2,5 +2,5 @@
2
2
 
3
3
  module KBSecret
4
4
  # kbsecret's current version
5
- VERSION = "0.6.0"
5
+ VERSION = "0.6.1"
6
6
  end
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: 0.6.0
4
+ version: 0.6.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: 2017-07-01 00:00:00.000000000 Z
11
+ date: 2017-07-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fpm