Class: Zold::Remove
- Inherits:
-
Object
- Object
- Zold::Remove
- Defined in:
- lib/zold/commands/remove.rb
Overview
REMOVE command
Instance Method Summary collapse
-
#initialize(wallets:, log: Log::Quiet.new) ⇒ Remove
constructor
A new instance of Remove.
- #remove(id, _) ⇒ Object
- #run(args = []) ⇒ Object
Constructor Details
Instance Method Details
#remove(id, _) ⇒ Object
52 53 54 55 56 57 58 |
# File 'lib/zold/commands/remove.rb', line 52 def remove(id, _) @wallets.find(id) do |w| raise "Wallet #{id} doesn't exist in #{w.path}" unless w.exists? File.delete(w.path) end @log.info("Wallet #{id} removed") end |
#run(args = []) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/zold/commands/remove.rb', line 40 def run(args = []) opts = Slop.parse(args, help: true, suppress_errors: true) do |o| o. = "Usage: zold remove [ID...] [options] Available options:" o.bool '--help', 'Print instructions' end mine = Args.new(opts, @log).take || return (mine.empty? ? @wallets.all : mine.map { |i| Id.new(i) }).each do |id| remove(id, opts) end end |