i2cssh 1.5.1 → 1.5.2

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.
Files changed (4) hide show
  1. data/VERSION +1 -1
  2. data/bin/i2cssh +34 -30
  3. data/i2cssh.gemspec +2 -2
  4. metadata +4 -4
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.5.1
1
+ 1.5.2
data/bin/i2cssh CHANGED
@@ -17,20 +17,14 @@ def get_hosts(c)
17
17
  cluster = @clusters[c]
18
18
 
19
19
  if cluster
20
- cluster_hosts = cluster["hosts"]
20
+ set_options(cluster, login_from_cli)
21
21
 
22
- @i2_options[:login_override] = !cluster["login"].nil? ? cluster["login"] : @i2_options[:login_override]
23
- @i2_options[:login_override] = login_from_cli if login_from_cli
24
- @i2_options[:broadcast] = !cluster["broadcast"].nil? ? cluster["broadcast"] : @i2_options[:broadcast]
25
- @i2_options[:profile] = !cluster["profile"].nil? ? cluster["profile"] : @i2_options[:profile]
26
- @i2_options[:rank] = !cluster["rank"].nil? ? cluster["rank"] : @i2_options[:rank]
22
+ cluster_hosts = cluster["hosts"]
27
23
 
28
24
  if @i2_options[:login_override] then
29
25
  cluster_hosts = cluster_hosts.map{|h| "#{@i2_options[:login_override]}@#{h}"}
30
26
  end
31
27
 
32
- @ssh_environment.merge!(cluster["environment"].inject({}){|m, v| m.merge(v)}) if cluster["environment"]
33
-
34
28
  @servers += cluster_hosts
35
29
  else
36
30
  puts "ERROR: unknown cluster #{c}. Check your #{@config_file}"
@@ -38,29 +32,37 @@ def get_hosts(c)
38
32
  end
39
33
  end
40
34
 
35
+ def set_options(config_hash, login_override=nil)
36
+ if login_override then
37
+ @i2_options[:login_override] = login_override
38
+ else
39
+ @i2_options[:login_override] = config_hash["login"].nil? ? @i2_options[:login_override] : config_hash["login"]
40
+ end
41
+
42
+ @i2_options[:broadcast] = config_hash["broadcast"].nil? ? @i2_options[:broadcast] : config_hash["broadcast"]
43
+ @i2_options[:profile] = config_hash["profile"].nil? ? @i2_options[:profile] : config_hash["profile"]
44
+ @i2_options[:rank] = config_hash["rank"].nil? ? @i2_options[:rank] : config_hash["rank"]
45
+ @i2_options[:iterm2] = config_hash["iterm2"].nil? ? @i2_options[:iterm2] : config_hash["iterm2"]
46
+
47
+ @ssh_environment.merge!(config_hash["environment"].inject({}){|m, v| m.merge(v)}) if config_hash["environment"]
48
+ end
49
+
41
50
  if File.exists?(@config_file)
42
51
  config_hash = YAML.load File.read @config_file
43
52
 
44
53
  # Read config and set defaults from config
45
54
  if config_hash["version"] && config_hash["version"].to_i >= 2 then
55
+ set_options(config_hash)
46
56
  @clusters = config_hash["clusters"]
47
-
48
- # Options from the config file
49
- @i2_options[:iterm2] = config_hash["iterm2"]
50
- @i2_options[:login_override] = config_hash["login"]
51
- @i2_options[:broadcast] = config_hash["broadcast"]
52
- @i2_options[:profile] = config_hash["profile"]
53
- @i2_options[:rank] = config_hash["rank"]
54
-
55
- @ssh_environment.merge!(config_hash["environment"].inject({}){|m, v| m.merge(v)}) if config_hash["environment"]
56
-
57
57
  else
58
58
  # Convert version 1 format to version 2
59
- clusters = config_hash["clusters"].inject({}){|m, c| m[c[0]] = {"hosts" => c[1]}; m}
59
+ @clusters = config_hash["clusters"].inject({}){|m, c| m[c[0]] = {"hosts" => c[1]}; m}
60
60
  end
61
61
 
62
62
  end
63
63
 
64
+ opts_from_cmdline = {}
65
+
64
66
  optparse = OptionParser.new do |opts|
65
67
  opts.banner = "Usage: #{File.basename(__FILE__)} [options] [(username@host [username@host] | username@cluster)]"
66
68
 
@@ -90,7 +92,7 @@ optparse = OptionParser.new do |opts|
90
92
  end
91
93
  opts.on '-l', '--login LOGIN',
92
94
  'SSH login name' do |u|
93
- @i2_options[:login_override] = u
95
+ opts_from_cmdline[:login_override] = u
94
96
 
95
97
  end
96
98
  opts.on '-e', '--environment KEY=VAL',
@@ -99,49 +101,49 @@ optparse = OptionParser.new do |opts|
99
101
  end
100
102
  opts.on '-r', '--rank',
101
103
  'Send LC_RANK with the host number as environment variable' do
102
- @i2_options[:rank] = true
104
+ opts_from_cmdline[:rank] = true
103
105
  end
104
106
 
105
107
  # iTerm2 options
106
108
  opts.on '-F', '--fullscreen',
107
109
  'Make the window fullscreen' do
108
- @i2_options[:fullscreen] = true
110
+ opts_from_cmdline[:fullscreen] = true
109
111
  end
110
112
  opts.on '-C', '--columns COLUMNS', Integer,
111
113
  'Number of columns (rows will be calculated)' do |c|
112
- if @i2_options[:rows]
114
+ if opts_from_cmdline[:rows]
113
115
  puts "ERROR: -C and -R can't be used at the same time"
114
116
  puts optparse.help
115
117
  exit 1
116
118
  else
117
- @i2_options[:columns] = c
119
+ opts_from_cmdline[:columns] = c
118
120
  end
119
121
  end
120
122
  opts.on '-R', '--rows ROWS', Integer,
121
123
  'Number of rows (columns will be calculated)' do |r|
122
- if @i2_options[:columns]
124
+ if opts_from_cmdline[:columns]
123
125
  puts "ERROR: -C and -R can't be used at the same time"
124
126
  puts optparse.help
125
127
  exit 1
126
128
  else
127
- @i2_options[:rows] = r
129
+ opts_from_cmdline[:rows] = r
128
130
  end
129
131
  end
130
132
  opts.on '-b', '--broadcast',
131
133
  'Start with broadcast input (DANGEROUS!)' do
132
- @i2_options[:broadcast] = true
134
+ opts_from_cmdline[:broadcast] = true
133
135
  end
134
136
  opts.on '-nb', '--nobroadcast',
135
137
  'Disable broadcast' do
136
- @i2_options[:broadcast] = false
138
+ opts_from_cmdline[:broadcast] = false
137
139
  end
138
140
  opts.on '-p', '--profile PROFILE',
139
141
  'Name of the iTerm2 profile (default: Default)' do |p|
140
- @i2_options[:profile] = p
142
+ opts_from_cmdline[:profile] = p
141
143
  end
142
144
  opts.on "-2", '--iterm2',
143
145
  'Use iTerm2 instead of iTerm' do
144
- @i2_options[:iterm2] = true
146
+ opts_from_cmdline[:iterm2] = true
145
147
  end
146
148
 
147
149
  end
@@ -154,6 +156,8 @@ elsif ARGV.length > 1 then
154
156
  @servers = ARGV
155
157
  end
156
158
 
159
+ @i2_options.merge!(opts_from_cmdline)
160
+
157
161
  if @i2_options[:login_override] then
158
162
  @servers = @servers.map{|h| "#{@i2_options[:login_override]}@#{h.gsub(/.+@/,'')}"}
159
163
  end
data/i2cssh.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "i2cssh"
8
- s.version = "1.5.1"
8
+ s.version = "1.5.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Wouter de Bie"]
12
- s.date = "2012-03-24"
12
+ s.date = "2012-03-25"
13
13
  s.description = "csshX like cluster ssh using iTerm2 panes"
14
14
  s.email = "wouter@evenflow.se"
15
15
  s.executables = ["i2cssh"]
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: i2cssh
3
3
  version: !ruby/object:Gem::Version
4
- hash: 1
4
+ hash: 7
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 5
9
- - 1
10
- version: 1.5.1
9
+ - 2
10
+ version: 1.5.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Wouter de Bie
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-03-24 00:00:00 Z
18
+ date: 2012-03-25 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  prerelease: false