Permalink
Browse files

Adding a --host auto option in favor of --ssh.

  • Loading branch information...
1 parent e2f42a2 commit 2810e700d25cd53d8c21e2c9b8d4ae6c4e4fc5d0 @JEG2 JEG2 committed Oct 28, 2011
Showing with 11 additions and 16 deletions.
  1. +11 −16 rmate
View
27 rmate
@@ -19,6 +19,10 @@ class Settings
@host = ENV['RMATE_HOST'].to_s if ENV.has_key? 'RMATE_HOST'
@port = ENV['RMATE_PORT'].to_i if ENV.has_key? 'RMATE_PORT'
+ if @host == 'auto' and (conn = ENV['SSH_CONNECTION'])
+ @host = conn.split(' ').first
+ end
+
@wait = false
@force = false
@verbose = false
@@ -33,25 +37,16 @@ class Settings
def parse_cli_options
OptionParser.new do |o|
- o.on( '--host=name', "Connect to host. Defaults to #{@host}.") { |v| @host = v }
- o.on('-p', '--port=#', Integer, "Port number to use for connection. Defaults to #{@port}.") { |v| @port = v }
- o.on('-w', '--[no-]wait', 'Wait for file to be closed by TextMate.') { |v| @wait = v }
- o.on('-f', '--force', 'Open even if the file is not writable.') { |v| @force = v }
- o.on('-v', '--verbose', 'Verbose logging messages.') { |v| @verbose = v }
- o.on('-s', '--ssh', 'Use the SSH connection to determine host.') { |v| detect_ssh_connection }
- o.on_tail('-h', '--help', 'Show this message.') { puts o; exit }
- o.on_tail( '--version', 'Show version.') { puts VERSION_STRING; exit }
+ o.on( '--host=name', "Connect to host. Use 'auto' to detect the host from SSH. Defaults to #{@host}.") { |v| @host = v }
+ o.on('-p', '--port=#', Integer, "Port number to use for connection. Defaults to #{@port}.") { |v| @port = v }
+ o.on('-w', '--[no-]wait', 'Wait for file to be closed by TextMate.') { |v| @wait = v }
+ o.on('-f', '--force', 'Open even if the file is not writable.') { |v| @force = v }
+ o.on('-v', '--verbose', 'Verbose logging messages.') { |v| @verbose = v }
+ o.on_tail('-h', '--help', 'Show this message.') { puts o; exit }
+ o.on_tail( '--version', 'Show version.') { puts VERSION_STRING; exit }
o.parse!
end
end
-
- private
-
- def detect_ssh_connection
- if conn = ENV['SSH_CONNECTION']
- @host = conn.split(' ').first
- end
- end
end
class Command

0 comments on commit 2810e70

Please sign in to comment.