Class: Zold::Fetch
- Inherits:
-
Object
- Object
- Zold::Fetch
- Defined in:
- lib/zold/commands/fetch.rb
Overview
FETCH pulling command
Instance Method Summary collapse
-
#initialize(wallets:, remotes:, copies:, log: Log::Quiet.new) ⇒ Fetch
constructor
A new instance of Fetch.
- #run(args = []) ⇒ Object
Constructor Details
#initialize(wallets:, remotes:, copies:, log: Log::Quiet.new) ⇒ Fetch
Returns a new instance of Fetch.
41 42 43 44 45 46 |
# File 'lib/zold/commands/fetch.rb', line 41 def initialize(wallets:, remotes:, copies:, log: Log::Quiet.new) @wallets = wallets @remotes = remotes @copies = copies @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 65 |
# File 'lib/zold/commands/fetch.rb', line 48 def run(args = []) opts = Slop.parse(args, help: true, suppress_errors: true) do |o| o. = "Usage: zold fetch [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 fetch from it', default: [] o.bool '--help', 'Print instructions' end mine = Args.new(opts, @log).take || return mine = @wallets.all if mine.empty? mine.map { |i| Id.new(i) }.each do |id| fetch(id, Copies.new(File.join(@copies, id)), opts) end end |