Class: Zold::Rebase

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

Overview

REBASE command

Instance Method Summary collapse

Constructor Details

#initialize(wallets:, log: Log::NULL) ⇒ Rebase

Returns a new instance of Rebase.



43
44
45
46
# File 'lib/zold/commands/rebase.rb', line 43

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

Instance Method Details

#run(args = []) ⇒ Object

Returns the array of modified wallets (IDs)



49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/zold/commands/rebase.rb', line 49

def run(args = [])
  opts = Slop.parse(args, help: true, suppress_errors: true) do |o|
    o.banner = "Usage: zold rebase [ID...] [options]
Available options:"
    o.bool '--help', 'Print instructions'
  end
  mine = Args.new(opts, @log).take || return
  list = mine.empty? ? @wallets.all : mine.map { |i| Id.new(i) }
  list.uniq.each do |id|
    rebase(id, opts)
  end
end