Class: Rubyists::Opr::Commands::Get

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

Overview

‘get’ command

Instance Attribute Summary

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(item, options) ⇒ Get

Returns a new instance of Get.



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

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

Instance Method Details

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

rubocop:disable Lint/UnusedMethodArgument



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/rubyists::opr/commands/get.rb', line 15

def execute(input: $stdin, output: $stdout) # rubocop:disable Lint/UnusedMethodArgument
  if options[:vault]
    vault = options[:vault]
  else
    split = @item.split('/', 2)
    vault, @item = split if split.size == 2
  end
  if vault.nil?
    warn 'No vault specified, using "Private"'
    vault = 'Private'
  end
  Opr. { output.puts Item.find(@item, vault: vault).password }
end