Class: KBSecret::CLI::Command::List
- Defined in:
- lib/kbsecret/cli/command/list.rb
Overview
The implementation of kbsecret list
.
Instance Attribute Summary
Attributes inherited from Abstract
Instance Method Summary collapse
-
#initialize(argv) ⇒ List
constructor
A new instance of List.
- #run! ⇒ Object
- #setup! ⇒ Object
Methods inherited from Abstract
command_name, config, #validate!
Constructor Details
#initialize(argv) ⇒ List
Returns a new instance of List.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/kbsecret/cli/command/list.rb', line 8 def initialize(argv) super(argv) do |cli| cli.slop do |o| o. = <<~HELP Usage: kbsecret list [options] HELP o.string "-s", "--session", "the session to list from", default: :default o.string "-t", "--type", "the type of secrets to list", default: nil o.bool "-a", "--show-all", "show everything in each secret (i.e. metadata)" end cli.ensure_type! if cli.opts[:type] cli.ensure_session! end end |
Instance Method Details
#run! ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/kbsecret/cli/command/list.rb', line 32 def run! @records.each do |record| puts record.label next unless cli.opts.show_all? puts <<~DETAIL \tType: #{record.type} \tLast changed: #{Time.at(record.)} \tRaw data: #{record.data} DETAIL end end |
#setup! ⇒ Object
27 28 29 |
# File 'lib/kbsecret/cli/command/list.rb', line 27 def setup! @records = cli.session.records TYPE_ALIASES[cli.opts[:type]] end |