hostmanager 1.0.4 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.4
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
- raise 'A host label can only be one letter or symbol' unless ARGV[1].length == 1
70
- (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_manager.host_list[ARGV[1]]
71
- host_manager.host_list[ARGV[1]] = ARGV[2] + ($zeroconf ? "(zeroconf)" : "")
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
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "hostmanager"
8
- s.version = "1.0.4"
8
+ s.version = "1.1.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Edmund Highcock"]
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>null"; system string)
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|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hostmanager
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: