Class: Zold::Clean

Inherits:
Object
  • Object
show all
Defined in:
lib/zold/commands/clean.rb

Overview

CLEAN pulling command

Instance Method Summary collapse

Constructor Details

#initialize(copies:, log: Log::Quiet.new) ⇒ Clean

Returns a new instance of Clean.



36
37
38
39
# File 'lib/zold/commands/clean.rb', line 36

def initialize(copies:, log: Log::Quiet.new)
  @copies = copies
  @log = log
end

Instance Method Details

#clean(cps, _) ⇒ Object



57
58
59
60
61
# File 'lib/zold/commands/clean.rb', line 57

def clean(cps, _)
  cps.clean
  @log.debug("Expired local copies removed for #{cps}, \
#{cps.all.count} left")
end

#run(args = []) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/zold/commands/clean.rb', line 41

def run(args = [])
  opts = Slop.parse(args, help: true) do |o|
    o.banner = "Usage: zold clean [ID...] [options]
Available options:"
    o.bool '--help', 'Print instructions'
  end
  if opts.help?
    @log.info(opts.to_s)
    return
  end
  raise 'At least one wallet ID is required' if opts.arguments.empty?
  opts.arguments.each do |id|
    clean(Copies.new(File.join(@copies, id)), opts)
  end
end