Class: Zold::Remote
- Inherits:
-
Object
- Object
- Zold::Remote
- Defined in:
- lib/zold/commands/remote.rb
Overview
Remote command
Instance Method Summary collapse
-
#initialize(remotes:, farm: Farm::Empty.new, log: Log::Quiet.new) ⇒ Remote
constructor
A new instance of Remote.
- #run(args = []) ⇒ Object
Constructor Details
Instance Method Details
#run(args = []) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/zold/commands/remote.rb', line 47 def run(args = []) opts = Slop.parse(args, help: true, suppress_errors: true) do |o| o. = "Usage: zold remote <command> [options] Available commands: #{Rainbow('remote show').green} Show all registered remote nodes #{Rainbow('remote clean').green} Remove all registered remote nodes #{Rainbow('remote reset').green} Restore it back to the default list of nodes #{Rainbow('remote add').green} host [port] Add a new remote node #{Rainbow('remote remove').green} host [port] Remove the remote node #{Rainbow('remote update').green} Check each registered remote node for availability Available options:" o.bool '--ignore-score-weakness', 'Don\'t complain when their score is too weak', default: false o.bool '--force', 'Add/remove if if this operation is not possible', default: false o.bool '--reboot', 'Exit if any node reports version higher than we have', default: false o.bool '--help', 'Print instructions' end mine = Args.new(opts, @log).take || return command = mine[0] raise "A command is required, try 'zold remote --help'" unless command case command when 'show' show when 'clean' clean when 'reset' reset when 'add' add(mine[1], mine[2] ? mine[2].to_i : Remotes::PORT, opts) when 'remove' remove(mine[1], mine[2] ? mine[2].to_i : Remotes::PORT, opts) when 'update' update(opts) update(opts, false) else raise "Unknown command '#{command}'" end end |