kbsecret 1.2.0 → 1.3.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.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +5 -5
  3. data/bin/kbsecret +6 -14
  4. data/lib/kbsecret/cli/command/abstract.rb +51 -0
  5. data/lib/kbsecret/cli/command/conf.rb +42 -0
  6. data/lib/kbsecret/cli/command/cp.rb +54 -0
  7. data/lib/kbsecret/cli/command/dump_fields.rb +53 -0
  8. data/lib/kbsecret/cli/command/env.rb +66 -0
  9. data/lib/kbsecret/cli/command/generator.rb +62 -0
  10. data/lib/kbsecret/cli/command/generators.rb +37 -0
  11. data/lib/kbsecret/cli/command/list.rb +48 -0
  12. data/lib/kbsecret/cli/command/login.rb +66 -0
  13. data/lib/kbsecret/cli/command/new.rb +82 -0
  14. data/lib/kbsecret/cli/command/pass.rb +51 -0
  15. data/lib/kbsecret/cli/command/raw_edit.rb +46 -0
  16. data/lib/kbsecret/cli/command/rm.rb +58 -0
  17. data/lib/kbsecret/cli/command/session.rb +128 -0
  18. data/lib/kbsecret/cli/command/sessions.rb +47 -0
  19. data/lib/kbsecret/cli/command/stash_file.rb +62 -0
  20. data/lib/kbsecret/cli/command/todo.rb +78 -0
  21. data/lib/kbsecret/cli/command.rb +45 -0
  22. data/lib/kbsecret/cli.rb +6 -4
  23. data/lib/kbsecret/config.rb +4 -3
  24. data/lib/kbsecret/record/abstract.rb +2 -2
  25. data/lib/kbsecret/record.rb +9 -7
  26. data/lib/kbsecret/version.rb +1 -1
  27. metadata +22 -20
  28. data/lib/kbsecret/cli/kbsecret-conf +0 -31
  29. data/lib/kbsecret/cli/kbsecret-cp +0 -44
  30. data/lib/kbsecret/cli/kbsecret-dump-fields +0 -39
  31. data/lib/kbsecret/cli/kbsecret-env +0 -53
  32. data/lib/kbsecret/cli/kbsecret-generator +0 -42
  33. data/lib/kbsecret/cli/kbsecret-generators +0 -28
  34. data/lib/kbsecret/cli/kbsecret-list +0 -36
  35. data/lib/kbsecret/cli/kbsecret-login +0 -53
  36. data/lib/kbsecret/cli/kbsecret-new +0 -68
  37. data/lib/kbsecret/cli/kbsecret-pass +0 -37
  38. data/lib/kbsecret/cli/kbsecret-raw-edit +0 -31
  39. data/lib/kbsecret/cli/kbsecret-rm +0 -44
  40. data/lib/kbsecret/cli/kbsecret-session +0 -105
  41. data/lib/kbsecret/cli/kbsecret-sessions +0 -38
  42. data/lib/kbsecret/cli/kbsecret-stash-file +0 -48
  43. data/lib/kbsecret/cli/kbsecret-todo +0 -47
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.2.0
4
+ version: 1.3.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-03-14 00:00:00.000000000 Z
11
+ date: 2018-03-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aruba
@@ -225,22 +225,24 @@ files:
225
225
  - bin/kbsecret
226
226
  - lib/kbsecret.rb
227
227
  - lib/kbsecret/cli.rb
228
- - lib/kbsecret/cli/kbsecret-conf
229
- - lib/kbsecret/cli/kbsecret-cp
230
- - lib/kbsecret/cli/kbsecret-dump-fields
231
- - lib/kbsecret/cli/kbsecret-env
232
- - lib/kbsecret/cli/kbsecret-generator
233
- - lib/kbsecret/cli/kbsecret-generators
234
- - lib/kbsecret/cli/kbsecret-list
235
- - lib/kbsecret/cli/kbsecret-login
236
- - lib/kbsecret/cli/kbsecret-new
237
- - lib/kbsecret/cli/kbsecret-pass
238
- - lib/kbsecret/cli/kbsecret-raw-edit
239
- - lib/kbsecret/cli/kbsecret-rm
240
- - lib/kbsecret/cli/kbsecret-session
241
- - lib/kbsecret/cli/kbsecret-sessions
242
- - lib/kbsecret/cli/kbsecret-stash-file
243
- - lib/kbsecret/cli/kbsecret-todo
228
+ - lib/kbsecret/cli/command.rb
229
+ - lib/kbsecret/cli/command/abstract.rb
230
+ - lib/kbsecret/cli/command/conf.rb
231
+ - lib/kbsecret/cli/command/cp.rb
232
+ - lib/kbsecret/cli/command/dump_fields.rb
233
+ - lib/kbsecret/cli/command/env.rb
234
+ - lib/kbsecret/cli/command/generator.rb
235
+ - lib/kbsecret/cli/command/generators.rb
236
+ - lib/kbsecret/cli/command/list.rb
237
+ - lib/kbsecret/cli/command/login.rb
238
+ - lib/kbsecret/cli/command/new.rb
239
+ - lib/kbsecret/cli/command/pass.rb
240
+ - lib/kbsecret/cli/command/raw_edit.rb
241
+ - lib/kbsecret/cli/command/rm.rb
242
+ - lib/kbsecret/cli/command/session.rb
243
+ - lib/kbsecret/cli/command/sessions.rb
244
+ - lib/kbsecret/cli/command/stash_file.rb
245
+ - lib/kbsecret/cli/command/todo.rb
244
246
  - lib/kbsecret/config.rb
245
247
  - lib/kbsecret/exceptions.rb
246
248
  - lib/kbsecret/generator.rb
@@ -268,9 +270,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
268
270
  version: 2.3.0
269
271
  required_rubygems_version: !ruby/object:Gem::Requirement
270
272
  requirements:
271
- - - ">="
273
+ - - ">"
272
274
  - !ruby/object:Gem::Version
273
- version: '0'
275
+ version: 1.3.1
274
276
  requirements: []
275
277
  rubyforge_project:
276
278
  rubygems_version: 2.7.3
@@ -1,31 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- require "kbsecret"
5
-
6
- include KBSecret
7
-
8
- cmd = CLI.create do |c|
9
- c.slop do |o|
10
- o.banner = <<~HELP
11
- Usage: kbsecret conf [options]
12
- HELP
13
-
14
- o.bool "-c", "--commands", "open the commands config (commands.ini)"
15
- o.bool "-d", "--directory", "print the path to the config directory"
16
- o.bool "-r", "--record-directory", "print the path to the custom record directory"
17
- end
18
- end
19
-
20
- KBSecret::CLI.die "You need to set $EDITOR!" unless ENV["EDITOR"]
21
-
22
- if cmd.opts.commands?
23
- exec "#{ENV["EDITOR"]} #{Config::COMMAND_CONFIG_FILE}"
24
- elsif cmd.opts.directory?
25
- puts Config::CONFIG_DIR
26
- elsif cmd.opts.record_directory?
27
- puts Config::CUSTOM_TYPES_DIR
28
- else
29
- exec "#{ENV["EDITOR"]} #{Config::CONFIG_FILE}"
30
- end
31
-
@@ -1,44 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- require "kbsecret"
5
- include KBSecret
6
-
7
- cmd = CLI.create do |c|
8
- c.slop do |o|
9
- o.banner = <<~HELP
10
- Usage:
11
- kbsecret cp [options] <source> <destination> <record [record ...]>
12
- HELP
13
-
14
- o.bool "-f", "--force", "force copying (ignore overwrites)"
15
- o.bool "-m", "--move", "delete the record after copying"
16
- end
17
-
18
- c.dreck do
19
- string :src_sess
20
- string :dst_sess
21
- list :string, :labels
22
- end
23
- end
24
-
25
- cmd.guard do
26
- src_sess = Session[cmd.args[:src_sess]]
27
- dst_sess = Session[cmd.args[:dst_sess]]
28
-
29
- selected_records = src_sess.records.select { |r| cmd.args[:labels].include?(r.label) }
30
- cmd.die "No such record(s)." if selected_records.empty?
31
-
32
- overlaps = dst_sess.record_labels & selected_records.map(&:label)
33
-
34
- # the code below actually handles the overwriting if necessary, but we fail early here for
35
- # friendliness and to avoid half-copying the selected records
36
- unless overlaps.empty? || cmd.opts.force?
37
- cmd.die "Refusing to overwrite existing record(s) without --force."
38
- end
39
-
40
- selected_records.each do |record|
41
- dst_sess.import_record(record, overwrite: cmd.opts.force?)
42
- src_sess.delete_record(label) if cmd.opts.move?
43
- end
44
- end
@@ -1,39 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- require "kbsecret"
5
-
6
- include KBSecret
7
-
8
- cmd = CLI.create do |c|
9
- c.slop do |o|
10
- o.banner = <<~HELP
11
- Usage:
12
- kbsecret dump-fields [options] <record>
13
- HELP
14
-
15
- o.string "-s", "--session", "the session to search in", default: :default
16
- o.bool "-x", "--terse", "output in field<sep>value format"
17
- o.string "-i", "--ifs", "separate terse pairs with this string", default: CLI.ifs
18
- end
19
-
20
- c.dreck do
21
- string :label
22
- end
23
-
24
- c.ensure_session!
25
- end
26
-
27
- label = cmd.args[:label]
28
- record = cmd.session[label]
29
-
30
- cmd.die "No such record." unless record
31
-
32
- field_values = record.data_fields.map { |f| record.send f }
33
- field_pairs = record.data_fields.zip(field_values)
34
-
35
- if cmd.opts.terse?
36
- puts field_pairs.map { |f, v| "#{f}#{cmd.opts[:ifs]}#{v}" }.join "\n"
37
- else
38
- puts field_pairs.map { |f, v| "#{f}: #{v}" }.join "\n"
39
- end
@@ -1,53 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- require "kbsecret"
5
-
6
- include KBSecret
7
-
8
- cmd = CLI.create do |c|
9
- c.slop do |o|
10
- o.banner = <<~HELP
11
- Usage:
12
- kbsecret env [options] <record [record ...]>
13
- HELP
14
-
15
- o.string "-s", "--session", "the session to search in", default: :default
16
- o.bool "-a", "--all", "retrieve all environment records, not just listed ones"
17
- o.bool "-v", "--value-only", "print only the environment value, not the key"
18
- o.bool "-n", "--no-export", "print only VAR=val keypairs without `export`"
19
- o.bool "-u", "--unescape-plus", "escape any pluses in the variable and/or value"
20
- end
21
-
22
- unless c.opts.all?
23
- c.dreck do
24
- list :string, :labels
25
- end
26
- end
27
-
28
- c.ensure_session!
29
- end
30
-
31
- records = cmd.session.records :environment
32
-
33
- selected_records = if cmd.opts.all?
34
- records
35
- else
36
- records.select do |record|
37
- cmd.args[:labels].include? record.label
38
- end
39
- end
40
-
41
- cmd.die "No such record(s)." if selected_records.empty?
42
-
43
- env_output = if cmd.opts.no_export?
44
- selected_records.map(&:to_assignment).join(" ")
45
- elsif cmd.opts.value_only?
46
- selected_records.map(&:value).join("\n")
47
- else
48
- selected_records.map(&:to_export).join("\n")
49
- end
50
-
51
- env_output.gsub!("\\+", "+") if cmd.opts.unescape_plus?
52
-
53
- puts env_output
@@ -1,42 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- require "kbsecret"
5
-
6
- include KBSecret
7
-
8
- cmd = CLI.create do |c|
9
- c.slop cmds: %w[new rm] do |o|
10
- o.banner = <<~HELP
11
- Usage:
12
- kbsecret generator [options] <new|rm> <generator>
13
- HELP
14
-
15
- o.string "-F", "--format", "the format of the secrets generated", default: "hex"
16
- o.integer "-l", "--length", "the length, in bytes, of the secrets generated",
17
- default: 16
18
- o.bool "-f", "--force", "force generator creation (ignore overwrite)"
19
- end
20
-
21
- c.dreck do
22
- string :command
23
- string :generator
24
- end
25
-
26
- c.ensure_generator! :argument if c.args[:command] == "rm"
27
- end
28
-
29
- case cmd.args[:command]
30
- when "new"
31
- if Config.generator?(cmd.args[:generator]) && !cmd.opts.force?
32
- cmd.die "Refusing to overwrite an existing generator without --force."
33
- end
34
-
35
- Config.configure_generator(cmd.args[:generator],
36
- format: cmd.opts[:format],
37
- length: cmd.opts[:length])
38
- when "rm"
39
- Config.deconfigure_generator(cmd.args[:generator])
40
- else
41
- cmd.die "Unknown subcommand: '#{cmd.args[:command]}'."
42
- end
@@ -1,28 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- require "kbsecret"
5
-
6
- include KBSecret
7
-
8
- cmd = CLI.create do |c|
9
- c.slop do |o|
10
- o.banner = <<~HELP
11
- Usage:
12
- kbsecret generators [options]
13
- HELP
14
-
15
- o.bool "-a", "--show-all", "show each generator in depth (i.e. metadata)"
16
- end
17
- end
18
-
19
- Config[:generators].each do |label, config|
20
- puts label
21
-
22
- next unless cmd.opts.show_all?
23
-
24
- puts <<~DETAIL
25
- \tFormat: #{config[:format]}
26
- \tLength: #{config[:length]}
27
- DETAIL
28
- end
@@ -1,36 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- require "kbsecret"
5
-
6
- include KBSecret
7
-
8
- cmd = CLI.create do |c|
9
- c.slop do |o|
10
- o.banner = <<~HELP
11
- Usage:
12
- kbsecret list [options]
13
- HELP
14
-
15
- o.string "-s", "--session", "the session to list from", default: :default
16
- o.string "-t", "--type", "the type of secrets to list", default: nil
17
- o.bool "-a", "--show-all", "show everything in each secret (i.e. metadata)"
18
- end
19
-
20
- c.ensure_type! if c.opts[:type]
21
- c.ensure_session!
22
- end
23
-
24
- records = cmd.session.records cmd.opts[:type]
25
-
26
- records.each do |record|
27
- puts record.label
28
-
29
- next unless cmd.opts.show_all?
30
-
31
- puts <<~DETAIL
32
- \tType: #{record.type}
33
- \tLast changed: #{Time.at(record.timestamp)}
34
- \tRaw data: #{record.data}
35
- DETAIL
36
- end
@@ -1,53 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- require "kbsecret"
5
-
6
- include KBSecret
7
-
8
- cmd = CLI.create do |c|
9
- c.slop do |o|
10
- o.banner = <<~HELP
11
- Usage:
12
- kbsecret login [options] <record [record ...]>
13
- HELP
14
-
15
- o.string "-s", "--session", "the session to search in", default: :default
16
- o.bool "-a", "--all", "retrieve all login records, not just listed ones"
17
- o.bool "-x", "--terse", "output in label<sep>username<sep>password format"
18
- o.string "-i", "--ifs", "separate terse fields with this string", default: CLI.ifs
19
- end
20
-
21
- unless c.opts.all?
22
- c.dreck do
23
- list :string, :labels
24
- end
25
- end
26
-
27
- c.ensure_session!
28
- end
29
-
30
- records = cmd.session.records :login
31
-
32
- selected_records = if cmd.opts.all?
33
- records
34
- else
35
- records.select do |record|
36
- cmd.args[:labels].include? record.label
37
- end
38
- end
39
-
40
- cmd.die "No such record(s)." if selected_records.empty?
41
-
42
- selected_records.each do |record|
43
- if cmd.opts.terse?
44
- fields = %i[label username password].map { |m| record.send(m) }
45
- puts fields.join(cmd.opts[:ifs])
46
- else
47
- puts <<~DETAIL
48
- Label: #{record.label}
49
- \tUsername: #{record.username}
50
- \tPassword: #{record.password}
51
- DETAIL
52
- end
53
- end
@@ -1,68 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- require "kbsecret"
5
- require "abbrev"
6
- require "tty-prompt"
7
-
8
- include KBSecret
9
-
10
- cmd = CLI.create do |c|
11
- c.slop do |o|
12
- o.banner = <<~HELP
13
- Usage:
14
- kbsecret new [options] <type> <label>
15
- HELP
16
-
17
- o.string "-s", "--session", "the session to contain the record", default: :default
18
- o.bool "-f", "--force", "force creation (ignore overwrites, etc.)"
19
- o.bool "-e", "--echo", "echo input to tty (only affects interactive input)"
20
- o.bool "-G", "--generate", "generate secret fields (interactive only)"
21
- o.string "-g", "--generator", "the generator to use for secret fields",
22
- default: :default
23
- o.bool "-x", "--terse", "read fields from input in a terse format"
24
- o.string "-i", "--ifs", "separate terse fields with this string", default: CLI.ifs
25
- end
26
-
27
- c.dreck do
28
- string :type
29
- string :label
30
- end
31
-
32
- c.ensure_generator!
33
- c.ensure_type! :argument
34
- c.ensure_session!
35
- end
36
-
37
- type = cmd.args[:type]
38
- label = cmd.args[:label]
39
- resolved_type = CLI::TYPE_ALIASES[type]
40
-
41
- # the code below actually handles the overwriting if necessary, but we fail early here
42
- # for friendliness and to avoid prompting the user for input unnecessarily
43
- if cmd.session.record?(label) && !cmd.opts.force?
44
- cmd.die "Refusing to overwrite an existing record without --force."
45
- end
46
-
47
- if cmd.opts.generate?
48
- generator = cmd.guard { Generator.new cmd.opts[:generator] }
49
- end
50
-
51
- fields = if cmd.opts.terse?
52
- STDIN.read.chomp.split cmd.opts[:ifs]
53
- else
54
- prompt = TTY::Prompt.new
55
- klass = Record.class_for(resolved_type)
56
- klass.external_fields.map do |field|
57
- if cmd.opts.generate? && klass.sensitive?(field)
58
- generator.secret
59
- else
60
- prompt.ask "#{field.capitalize}?",
61
- echo: !klass.sensitive?(field) || cmd.opts.echo?
62
- end
63
- end
64
- end
65
-
66
- cmd.guard do
67
- cmd.session.add_record resolved_type, label, *fields, overwrite: cmd.opts.force?
68
- end
@@ -1,37 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- require "kbsecret"
5
- require "clipboard"
6
-
7
- include KBSecret
8
-
9
- cmd = CLI.create do |c|
10
- c.slop do |o|
11
- o.banner = <<~HELP
12
- Usage:
13
- kbsecret pass [options] <record>
14
- HELP
15
-
16
- o.string "-s", "--session", "the session to search in", default: :default
17
- o.bool "-c", "--clipboard", "dump the password in the clipboard"
18
- end
19
-
20
- c.dreck do
21
- string :label
22
- end
23
-
24
- c.ensure_session!
25
- end
26
-
27
- label = cmd.args[:label]
28
- record = cmd.session[label]
29
-
30
- cmd.die "No such record." unless record
31
- cmd.die "'#{record}' is not a login record." unless record.type == :login
32
-
33
- if cmd.opts.clipboard?
34
- Clipboard.copy record.password
35
- else
36
- puts record.password
37
- end
@@ -1,31 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- require "kbsecret"
5
-
6
- include KBSecret
7
-
8
- cmd = CLI.create do |c|
9
- c.slop do |o|
10
- o.banner = <<~HELP
11
- Usage:
12
- kbsecret raw-edit [options] <record>
13
- HELP
14
-
15
- o.string "-s", "--session", "the session to search in", default: :default
16
- end
17
-
18
- c.dreck do
19
- string :label
20
- end
21
-
22
- c.ensure_session!
23
- end
24
-
25
- label = cmd.args[:label]
26
- record = cmd.session[label]
27
-
28
- cmd.die "No such record." unless record
29
-
30
- Process.spawn("#{ENV["EDITOR"]} #{record.path}")
31
- record.sync! # just to bump the timestamp
@@ -1,44 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- require "kbsecret"
5
- require "tty-prompt"
6
-
7
- include KBSecret
8
-
9
- $VERBOSE = nil # tty-prompt blasts us with irrelevant warnings on 2.4
10
-
11
- cmd = CLI.create do |c|
12
- c.slop do |o|
13
- o.banner = <<~HELP
14
- Usage:
15
- kbsecret rm [options] <record [record ...]>
16
- HELP
17
-
18
- o.string "-s", "--session", "the session containing the record", default: :default
19
- o.bool "-i", "--interactive", "ask for confirmation before deleting"
20
- end
21
-
22
- c.dreck do
23
- list :string, :labels
24
- end
25
-
26
- c.ensure_session!
27
- end
28
-
29
- records = cmd.session.records
30
-
31
- selected_records = records.select do |record|
32
- cmd.args[:labels].include? record.label
33
- end
34
-
35
- cmd.die "No such record(s)." if selected_records.empty?
36
-
37
- tty = TTY::Prompt.new
38
-
39
- confirm = if cmd.opts.interactive?
40
- tty.yes?("Delete '#{selected_records.join(", ")}' from the #{cmd.session.label} session?")
41
- else true
42
- end
43
-
44
- selected_records.each { |r| cmd.session.delete_record(r.label) } if confirm
@@ -1,105 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- require "kbsecret"
5
-
6
- include KBSecret
7
-
8
- def new_session(label, cmd)
9
- if Config.session?(label) && !cmd.opts.force?
10
- cmd.die "Refusing to overwrite an existing session without --force."
11
- end
12
-
13
- if cmd.opts[:team]
14
- teams = Keybase::Local::Team.list_self_memberships.teams
15
-
16
- unless teams.map(&:fq_name).include?(cmd.opts[:team])
17
- if cmd.opts.create_team?
18
- cmd.guard do
19
- Keybase::Local::Team.create_team cmd.opts[:team]
20
- Keybase::Local::Team.add_members cmd.opts[:team], users: [{
21
- username: Keybase::Local.current_user,
22
- role: "admin",
23
- }]
24
- end
25
- else
26
- cmd.die "No such team (either nonexistent or non-member)."
27
- end
28
- end
29
-
30
- Config.configure_session(label, team: cmd.opts[:team], root: label)
31
- else
32
- cmd.die "Missing `-r', `--root' option." unless cmd.opts[:root]
33
-
34
- cmd.opts[:users].each do |user|
35
- cmd.die "Nonexistent Keybase user: '#{user}'." unless Keybase::API.user? user
36
- end
37
-
38
- unless cmd.opts[:users].include? Keybase::Local.current_user
39
- cmd.warn "You didn't include yourself in the user list, but I'll add you."
40
- cmd.opts[:users] << Keybase::Local.current_user
41
- end
42
-
43
- Config.configure_session(label, users: cmd.opts[:users], root: cmd.opts[:root])
44
-
45
- unless cmd.opts.no_notify? && cmd.opts[:users] != [Keybase::Local.current_user]
46
- users = cmd.opts[:users].join(",")
47
-
48
- Keybase::Local::Chat.send_message cmd.opts[:users], <<~MESSAGE
49
- You've been added to a KBSecret session!
50
-
51
- To access this session, please run the following:
52
-
53
- ```
54
- $ kbsecret session new -r '#{cmd.opts[:root]}' -u #{users} <label>
55
- ```
56
-
57
- If you don't have KBSecret installed, you can install it from `gem`:
58
-
59
- ```
60
- $ gem install kbsecret
61
- ```
62
- MESSAGE
63
- end
64
- end
65
- end
66
-
67
- def rm_session(label, cmd)
68
- cmd.session.unlink! if cmd.opts.delete?
69
- Config.deconfigure_session label
70
- end
71
-
72
- cmd = CLI.create do |c|
73
- c.slop cmds: %w[new rm] do |o|
74
- o.banner = <<~HELP
75
- Usage:
76
- kbsecret session [options] <new|rm> <label>
77
- HELP
78
-
79
- o.string "-t", "--team", "the team to create the session under"
80
- o.array "-u", "--users", "the Keybase users", default: [Keybase::Local.current_user]
81
- o.string "-r", "--root", "the secret root directory"
82
- o.bool "-c", "--create-team", "create the Keybase team if it does not exist"
83
- o.bool "-f", "--force", "force creation (ignore overwrites, etc.)"
84
- o.bool "-n", "--no-notify", "do not send a notification to session members"
85
- o.bool "-d", "--delete", "unlink the session in addition to deconfiguration"
86
- end
87
-
88
- c.dreck do
89
- string :command
90
- string :session
91
- end
92
-
93
- c.ensure_session! :argument if c.args[:command] == "rm"
94
- end
95
-
96
- session_label = cmd.args[:session]
97
-
98
- case cmd.args[:command]
99
- when "new"
100
- new_session session_label, cmd
101
- when "rm"
102
- rm_session session_label, cmd
103
- else
104
- cmd.die "Unknown subcommand: '#{cmd.args[:command]}'."
105
- end