Class: ItsyBtc::Commands::DeleteCommand

Inherits:
Command
  • Object
show all
Defined in:
lib/itsy-btc/commands/delete_command.rb

Instance Attribute Summary

Attributes inherited from Command

#wallet

Instance Method Summary collapse

Methods inherited from Command

args, name, summary

Constructor Details

#initialize(address) ⇒ DeleteCommand

Returns a new instance of DeleteCommand.



8
9
10
# File 'lib/itsy-btc/commands/delete_command.rb', line 8

def initialize(address)
  @address = address.to_s
end

Instance Method Details

#runObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/itsy-btc/commands/delete_command.rb', line 12

def run
  if @wallet.nil?
    puts "No wallet found. Run `itsy init` to create one."
    exit
  end

  key = @wallet.key_for_address(@address)
  if @wallet.remove(@address)
    puts "Address #{@address} deleted."
    puts "Here is the key in case you made a mistake: #{key}"
  else
    puts "There is no address #{@address} in your wallet."
  end
end