Class: Rubyists::Opr::Commands::List::Items

Inherits:
Rubyists::Opr::Command show all
Defined in:
lib/rubyists::opr/commands/list/items.rb

Overview

Items subcommand

Instance Attribute Summary collapse

Attributes inherited from Rubyists::Opr::Command

#options

Instance Method Summary collapse

Methods inherited from Rubyists::Opr::Command

#command, #cursor, #editor, #exec_exist?, #generator, #pager, #platform, #prompt, #screen, #which

Constructor Details

#initialize(vault, options) ⇒ Items

Returns a new instance of Items.



12
13
14
15
# File 'lib/rubyists::opr/commands/list/items.rb', line 12

def initialize(vault, options)
  @vault = vault
  @options = options
end

Instance Attribute Details

#vaultObject (readonly)

Returns the value of attribute vault.



11
12
13
# File 'lib/rubyists::opr/commands/list/items.rb', line 11

def vault
  @vault
end

Instance Method Details

#execute(input: $stdin, output: $stdout) ⇒ Object

rubocop:disable Lint/UnusedMethodArgument



17
18
19
20
21
22
23
24
# File 'lib/rubyists::opr/commands/list/items.rb', line 17

def execute(input: $stdin, output: $stdout) # rubocop:disable Lint/UnusedMethodArgument
  if vault.nil?
    warn 'Using vault "Private" since none was given'
    @vault = 'Private'
  end
  # Command logic goes here ...
  Opr. { output.puts Vault.find_by_name(vault).items.map(&:title) }
end