bin/i2cssh in i2cssh-1.0.0 vs bin/i2cssh in i2cssh-1.1.0
- old
+ new
@@ -8,39 +8,43 @@
optparse = OptionParser.new do |opts|
opts.banner = "Usage: #{File.basename(__FILE__)} [options]"
options[:debug] = false
options[:fullscreen] = false
opts.on('-d', '--debug', "Start RIPL after creating terminals") { options[:debug] = true }
- opts.on('-f', '--file FILE', "Cluster file") { |f| options[:file] = f }
+ opts.on('-A', '--forward-agent', "Enable SSH agent forwarding") { options[:forward] = true }
+ opts.on('-f', '--file FILE', "Cluster file (one hostname per line)") { |f| options[:file] = f }
opts.on('-F', '--fullscreen', "Fullscreen") { options[:fullscreen] = true }
- opts.on('-u', '--username USERNAME', "SSH username") { |u| options[:username] = u }
+ opts.on('-l', '--login LOGIN', "SSH login name") { |u| options[:login] = u }
opts.on('-c', '--cluster CLUSTERNAME', "Name of the cluster specified in ~/.i2csshrc") { |c| options[:cluster] = c }
+ opts.on('-m', '--machines a,b,c', Array, "Comma-separated list of hosts") { |h| options[:hosts] = h }
opts.on('-C', '--columns COLUMNS', "Amount of columns (rows will be calculated)") { |c| options[:columns] = c }
opts.on('-R', '--rows ROWS', "Amount of rows (columns will be calculated)") { |r| options[:rows] = r }
# opts.on('-s', '--session SESSIONNAME', "Name of an iTerm2 session") { |s| options[:session_name] = s }
end
optparse.parse!
-unless options[:file] || options[:cluster] then
+unless options[:file] || options[:cluster] || options[:hosts] then
puts optparse.help
exit
end
-if options[:file] && options[:cluster] then
- puts "ERROR: -f and -c can't be used at the same time"
+if [ options[:file], options[:cluster], options[:hosts] ].compact.length > 1 then
+ puts "ERROR: neither -f, -c or -h can be combined"
puts optparse.help
exit
end
if options[:columns] && options[:rows] then
puts "ERROR: -C and -R can't be used at the same time"
puts optparse.help
exit
end
-ssh_prefix = "ssh " + (options[:username] ? "#{options[:username]}@" : "")
+ssh_prefix = "ssh " +
+ (options[:forward] ? "-A " : "") +
+ (options[:login] ? "-l #{options[:login]} " : "")
rows = options[:rows].to_i if options[:rows]
columns = options[:columns].to_i if options[:columns]
@@ -48,9 +52,11 @@
servers = File.read(options[:file]).split("\n")
elsif options[:cluster] then
require 'yaml'
config_hash = YAML.load(File.read(File.expand_path("~/.i2csshrc")))
servers = config_hash["clusters"][options[:cluster]]
+elsif options[:hosts] then
+ servers = options[:hosts]
end
count = servers.size
if rows then
columns = (count / rows.to_f).ceil