class KBSecret::CLI::Command::Sessions

The implementation of `kbsecret sessions`.

Public Class Methods

new(argv) click to toggle source
Calls superclass method KBSecret::CLI::Command::Abstract::new
# File lib/kbsecret/cli/command/sessions.rb, line 8
        def initialize(argv)
          super(argv) do |cli|
            cli.slop do |o|
              o.banner = <<~HELP
                Usage:
                  kbsecret sessions [options]
              HELP

              o.bool "-a", "--show-all", "show each session in depth (i.e. metadata)"
            end
          end
        end

Public Instance Methods

run!() click to toggle source

@see Command::Abstract#run!

# 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 <<~DETAIL
                \tTeam: #{session_hash[:team]}
                \tSecrets root: #{session_hash[:root]} (#{session.path})
              DETAIL
            else
              puts <<~DETAIL
                \tUsers: #{session_hash[:users].join(", ")}
                \tSecrets root: #{session_hash[:root]} (#{session.path})
              DETAIL
            end
          end
        end