class Rubyists::Opr::Commands::Rm

the rm command

Public Class Methods

new(item, options) click to toggle source
# File lib/rubyists::opr/commands/rm.rb, line 11
def initialize(item, options)
  @item = item
  @options = options
end

Public Instance Methods

execute(input: $stdin, output: $stdout) click to toggle source
# File lib/rubyists::opr/commands/rm.rb, line 16
def execute(input: $stdin, output: $stdout) # rubocop:disable Lint/UnusedMethodArgument
  vault_name = if options[:vault]
                 options[:vault]
               else
                 warn 'No vault given, using "Private"'
                 'Private'
               end
  Opr.with_login do
    found = Item.find(@item, vault: vault_name)
    return(output.puts("No item '#{@item}' found in vault '#{vault_name}'")) if found.nil?

    found.delete!
    output.puts "Removed '#{@item}' from '#{vault_name}'"
  end
end