Class: Zold::Diff

Inherits:
Object
  • Object
show all
Includes:
ThreadBadge
Defined in:
lib/zold/commands/diff.rb

Overview

DIFF pulling command

Instance Method Summary collapse

Constructor Details

#initialize(wallets:, copies:, log: Loog::NULL) ⇒ Diff

Returns a new instance of Diff.



25
26
27
28
29
# File 'lib/zold/commands/diff.rb', line 25

def initialize(wallets:, copies:, log: Loog::NULL)
  @wallets = wallets
  @copies = copies
  @log = log
end

Instance Method Details

#run(args = []) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/zold/commands/diff.rb', line 31

def run(args = [])
  opts = Slop.parse(args, help: true, suppress_errors: true) do |o|
    o.banner = "Usage: zold diff [ID...] [options]
Available options:"
    o.bool '--help', 'Print instructions'
  end
  mine = Args.new(opts, @log).take || return
  raise 'At least one wallet ID is required' if mine.empty?
  stdout = ''
  mine.map { |i| Id.new(i) }.each do |id|
    stdout += diff(id, Copies.new(File.join(@copies, id)), opts)
  end
  stdout
end