Class: Zold::Push

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

Overview

Wallet pushing command

Instance Method Summary collapse

Constructor Details

#initialize(wallets:, remotes:, log: Log::Quiet.new) ⇒ Push

Returns a new instance of Push.



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

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

Instance Method Details

#run(args = []) ⇒ Object



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/zold/commands/push.rb', line 48

def run(args = [])
  opts = Slop.parse(args, help: true, suppress_errors: true) do |o|
    o.banner = "Usage: zold push [ID...] [options]
Available options:"
    o.bool '--ignore-score-weakness',
      'Don\'t complain when their score is too weak',
      default: false
    o.array '--ignore-node',
      'Ignore this node and don\'t push to it',
      default: []
    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|
    push(id, opts)
  end
end