hostmanager 1.0.4 → 1.1.0
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/VERSION +1 -1
- data/bin/hm +3 -3
- data/hostmanager.gemspec +1 -1
- data/lib/hostmanager.rb +18 -1
- metadata +1 -1
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0
|
1
|
+
1.1.0
|
data/bin/hm
CHANGED
@@ -66,9 +66,9 @@ HostManager.phoenix($default_host_manager_store) do |host_manager|
|
|
66
66
|
end
|
67
67
|
puts "\n#############################################\n\n"
|
68
68
|
when 'add'
|
69
|
-
|
70
|
-
(puts
|
71
|
-
host_manager.
|
69
|
+
#host_manager.host_list[ARGV[1]] = ARGV[2] + ($zeroconf ? "(zeroconf)" : "")
|
70
|
+
(puts "Please specify a letter and a URL; e.g. hm add m myname@myhost.com"; exit) unless ARGV[1].is_a? String and ARGV[2].is_a? String
|
71
|
+
host_manager.add(ARGV[1], ARGV[2] + ($zeroconf ? "(zeroconf)" : ""))
|
72
72
|
when 'pf', 'portforward'
|
73
73
|
$command = host_manager.port_forward(*ARGV[-1].split(//))
|
74
74
|
when 'ssh'
|
data/hostmanager.gemspec
CHANGED
data/lib/hostmanager.rb
CHANGED
@@ -158,6 +158,8 @@ class HostManager
|
|
158
158
|
set(key, value)
|
159
159
|
end
|
160
160
|
@host_list ||= {}
|
161
|
+
@host_list['h'] = ''
|
162
|
+
@host_list['l'] = ENV['USER'] + '@localhost'
|
161
163
|
@host_list.each do |letter, string|
|
162
164
|
string.sub!(/:$/, '')
|
163
165
|
end
|
@@ -168,7 +170,7 @@ class HostManager
|
|
168
170
|
@host_list.each do |letter, host_string|
|
169
171
|
if @forwards[letter]
|
170
172
|
@hosts[letter] = Host::Forwarded.from_string(host_string, @forwards[letter])
|
171
|
-
unless (string = "#{@hosts[letter].ssh} cd . 2
|
173
|
+
unless (string = "#{@hosts[letter].ssh} cd . 2>/dev/null"; system string)
|
172
174
|
# puts 'port failed'
|
173
175
|
@forwards.delete(letter)
|
174
176
|
@hosts[letter] = Host.from_string(host_string)
|
@@ -184,6 +186,21 @@ class HostManager
|
|
184
186
|
end
|
185
187
|
end
|
186
188
|
end
|
189
|
+
def add(letter, hosturl)
|
190
|
+
raise 'A host label can only be one letter or symbol' unless letter.length == 1
|
191
|
+
case letter
|
192
|
+
when "h"
|
193
|
+
puts "h can only be used to mean 'home', i.e. an empty string"
|
194
|
+
return
|
195
|
+
when "l"
|
196
|
+
puts "l can only be used to mean $USER@localhost"
|
197
|
+
return
|
198
|
+
else
|
199
|
+
(puts 'This host already exists. Do you want to replace it? Press enter to replace it or Ctrl + C to cancel.'; $stdin.gets) if host_list[letter]
|
200
|
+
host_list[letter] = hosturl
|
201
|
+
end
|
202
|
+
end
|
203
|
+
|
187
204
|
def inspect
|
188
205
|
@hosts = "Don't edit this variable"
|
189
206
|
hash = instance_variables.inject({}) do |hash, var|
|