Sha256: 41af221020b647f90ead7933a6351bc72541305232d00b778b72da2bed9a13fa

Contents?: true

Size: 748 Bytes

Versions: 6

Compression:

Stored size: 748 Bytes

Contents

$:.unshift File.join(File.dirname(__FILE__), "../lib")

require "readline"
require "weave"

usage = <<-EOS
Usage:
  $ ruby parallel-console.rb user@host1 user@host2 ...
EOS

abort usage if ARGV.empty?

$stty_state = `stty -g`.chomp
$pool = Weave.connect(ARGV)

prompt = ">>> "
while command = Readline.readline(prompt, true)
  prompt = ">>> "
  break unless command # ctrl-D
  command.chomp!
  next if command.empty?
  break if ["exit", "quit"].include? command
  bad_exit = false
  $pool.execute do
    result = run(command, :continue_on_failure => true)
    bad_exit = result[:exit_code] && result[:exit_code] != 0
    bad_exit ||= result[:exit_signal]
  end
  prompt = "!!! " if bad_exit
end

$pool.disconnect!
`stty #{$stty_state}`
puts "Bye."

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
weave-1.1.0.pre.beta1 examples/parallel-console.rb
weave-1.0.2.beta1 examples/parallel-console.rb
weave-1.0.1 examples/parallel-console.rb
weave-1.0.0 examples/parallel-console.rb
weave-0.2.0 examples/parallel-console.rb
weave-0.1.0 examples/parallel-console.rb