Class: KBSecret::CLI::Command::Sessions

Inherits:
Abstract
  • Object
show all
Defined in:
lib/kbsecret/cli/command/sessions.rb

Overview

The implementation of kbsecret sessions.

Instance Attribute Summary

Attributes inherited from Abstract

#cli

Instance Method Summary collapse

Methods inherited from Abstract

command_name, config, #setup!, #validate!

Constructor Details

#initialize(argv) ⇒ Sessions

Returns a new instance of Sessions.



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/kbsecret/cli/command/sessions.rb', line 8

def initialize(argv)
  super(argv) do |cli|
    cli.slop do |o|
      o.banner = "        Usage:\n          kbsecret sessions [options]\n      HELP\n\n      o.bool \"-a\", \"--show-all\", \"show each session in depth (i.e. metadata)\"\n    end\n  end\nend\n"

Instance Method Details

#run!Object

See Also:



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/kbsecret/cli/command/sessions.rb', line 22

def run!
  Config.session_labels.each do |sess_name|
    session_hash = Config.session(sess_name)
    session      = KBSecret::Session[sess_name]

    puts sess_name

    next unless cli.opts.show_all?

    if session_hash[:team]
      puts "        \\tTeam: \#{session_hash[:team]}\n        \\tSecrets root: \#{session_hash[:root]} (\#{session.path})\n      DETAIL\n    else\n      puts <<~DETAIL\n        \\tUsers: \#{session_hash[:users].join(\", \")}\n        \\tSecrets root: \#{session_hash[:root]} (\#{session.path})\n      DETAIL\n    end\n  end\nend\n"