i2cssh 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.markdown +2 -1
- data/VERSION +1 -1
- data/bin/i2cssh +30 -13
- data/i2cssh.gemspec +1 -1
- metadata +3 -3
data/README.markdown
CHANGED
@@ -14,9 +14,10 @@ to all sessions.
|
|
14
14
|
-d, --debug Start RIPL after creating terminals
|
15
15
|
-f, --file FILE Cluster file
|
16
16
|
-F, --fullscreen Fullscreen
|
17
|
-
-g, --grid WxH Grid size
|
18
17
|
-u, --username USERNAME SSH username
|
19
18
|
-c, --cluster CLUSTERNAME Name of the cluster specified in ~/.i2csshrc
|
19
|
+
-C, --columns COLUMNS Amount of columns (rows will be calculated)
|
20
|
+
-R, --rows ROWS Amount of rows (columns will be calculated)
|
20
21
|
|
21
22
|
The cluster file format is one host per line.
|
22
23
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.4
|
data/bin/i2cssh
CHANGED
@@ -5,9 +5,6 @@ require 'optparse'
|
|
5
5
|
|
6
6
|
options = {}
|
7
7
|
|
8
|
-
rows = nil
|
9
|
-
columns = nil
|
10
|
-
|
11
8
|
optparse = OptionParser.new do |opts|
|
12
9
|
opts.banner = "Usage: #{File.basename(__FILE__)} [options]"
|
13
10
|
options[:debug] = false
|
@@ -15,31 +12,39 @@ optparse = OptionParser.new do |opts|
|
|
15
12
|
opts.on('-d', '--debug', "Start RIPL after creating terminals") { options[:debug] = true }
|
16
13
|
opts.on('-f', '--file FILE', "Cluster file") { |f| options[:file] = f }
|
17
14
|
opts.on('-F', '--fullscreen', "Fullscreen") { options[:fullscreen] = true }
|
18
|
-
opts.on('-g', '--grid WxH', "Grid size") { |f| options[:grid] = f.split("x")}
|
19
15
|
opts.on('-u', '--username USERNAME', "SSH username") { |u| options[:username] = u }
|
20
16
|
opts.on('-c', '--cluster CLUSTERNAME', "Name of the cluster specified in ~/.i2csshrc") { |c| options[:cluster] = c }
|
17
|
+
opts.on('-C', '--columns COLUMNS', "Amount of columns (rows will be calculated)") { |c| options[:columns] = c }
|
18
|
+
opts.on('-R', '--rows ROWS', "Amount of rows (columns will be calculated)") { |r| options[:rows] = r }
|
21
19
|
end
|
22
20
|
|
23
21
|
optparse.parse!
|
24
22
|
|
25
|
-
unless options[:file] || options[:
|
23
|
+
unless options[:file] || options[:cluster] then
|
24
|
+
puts optparse.help
|
25
|
+
exit
|
26
|
+
end
|
27
|
+
|
28
|
+
if options[:file] && options[:cluster] then
|
29
|
+
puts "ERROR: -f and -c can't be used at the same time"
|
26
30
|
puts optparse.help
|
27
31
|
exit
|
28
32
|
end
|
29
33
|
|
30
|
-
if options[:
|
31
|
-
puts "ERROR: -
|
34
|
+
if options[:columns] && options[:rows] then
|
35
|
+
puts "ERROR: -C and -R can't be used at the same time"
|
32
36
|
puts optparse.help
|
33
37
|
exit
|
34
38
|
end
|
35
39
|
|
36
40
|
ssh_prefix = "ssh " + (options[:username] ? "#{options[:username]}@" : "")
|
37
41
|
|
42
|
+
rows = options[:rows].to_i if options[:rows]
|
43
|
+
columns = options[:columns].to_i if options[:columns]
|
44
|
+
|
45
|
+
|
38
46
|
if options[:file] then
|
39
47
|
servers = File.read(options[:file]).split("\n")
|
40
|
-
elsif options[:grid] then
|
41
|
-
columns = options[:grid][0].to_i
|
42
|
-
rows = options[:grid][1].to_i
|
43
48
|
elsif options[:cluster] then
|
44
49
|
require 'yaml'
|
45
50
|
config_hash = YAML.load(File.read(File.expand_path("~/.i2csshrc")))
|
@@ -47,20 +52,32 @@ elsif options[:cluster] then
|
|
47
52
|
end
|
48
53
|
|
49
54
|
count = servers.size
|
50
|
-
rows
|
51
|
-
columns
|
55
|
+
if rows then
|
56
|
+
columns = (count / rows.to_f).ceil
|
57
|
+
elsif columns then
|
58
|
+
rows = (count / columns.to_f).ceil
|
59
|
+
else
|
60
|
+
rows = Math.sqrt(count).ceil
|
61
|
+
columns = (count / rows.to_f).ceil
|
62
|
+
end
|
63
|
+
|
64
|
+
#rows ||= Math.sqrt(count).ceil
|
65
|
+
#columns ||= (count / rows.to_f).ceil
|
52
66
|
|
53
67
|
iterm = Appscript.app.by_name('iTerm')
|
54
68
|
finder = Appscript.app.by_name('Finder')
|
55
69
|
sys_events = Appscript.app.by_name('System Events')
|
56
70
|
|
57
|
-
|
71
|
+
puts rows
|
72
|
+
puts columns
|
73
|
+
puts servers.inspect
|
58
74
|
|
59
75
|
term = iterm.make(:new => :terminal)
|
60
76
|
session = term.sessions.after.make(:new => :session)
|
61
77
|
session.exec(:command => "/bin/bash -l")
|
62
78
|
|
63
79
|
if options[:fullscreen] then
|
80
|
+
window_bounds = finder.desktop.window.bounds
|
64
81
|
window = iterm.windows.get.sort_by{|x| x.id_.get}.last
|
65
82
|
window.bounds.set(window_bounds.get)
|
66
83
|
end
|
data/i2cssh.gemspec
CHANGED
metadata
CHANGED