Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tag: r0.2.3
Fetching contributors…

Cannot retrieve contributors at this time

executable file 45 lines (34 sloc) 0.911 kb
#!/usr/bin/env ruby
require 'optparse'
optparse = OptionParser.new do |opts|
opts.banner = "Usage: ndo [options] HOST_SET COMMAND"
end
optparse.parse!
unless ARGV.size >= 2
puts optparse
puts
puts "You need to specify at least a host set and a command."
exit 1
end
host_set, *cmd_parts = ARGV
command = cmd_parts.join(' ')
hosts = File.read(
File.join(ENV['HOME'], '.ndo', host_set)).
lines.map { |l| l.chomp.strip }
$:.unshift File.dirname(__FILE__) + "/../lib"
require 'ndo'
require 'text/highlight'
hl = Text::ANSIHighlighter.new
String.highlighter = hl
results = Ndo::MultiHost.new(hosts).run(command)
results.each do |host, result|
output = result.stdout.chomp
if output.index("\n")
# Multiline output
output.gsub!(/\n/, "\n ")
output = " "+output
printf "%s {\n%s}\n\n", host.bold, output
else
printf "%-20s %s\n", host.bold, output
end
end
Jump to Line
Something went wrong with that request. Please try again.