Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Defaulting to an SSH tunnel friendly configuration and leaving the ol…

…d connection semantics available as a new option.
  • Loading branch information...
commit e2f42a2dc5fb7557d115536b5231dc8d9bf7fcc4 1 parent 5d6a14a
@JEG2 JEG2 authored
Showing with 17 additions and 12 deletions.
  1. +17 −12 rmate
View
29 rmate
@@ -14,11 +14,7 @@ class Settings
attr_accessor :host, :port, :wait, :force, :verbose
def initialize
- @host, @port = '127.0.0.1', 52698
-
- if conn = ENV['SSH_CONNECTION']
- @host = conn.split(' ').first
- end
+ @host, @port = 'localhost', 52698
@host = ENV['RMATE_HOST'].to_s if ENV.has_key? 'RMATE_HOST'
@port = ENV['RMATE_PORT'].to_i if ENV.has_key? 'RMATE_PORT'
@@ -37,16 +33,25 @@ 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_tail('-h', '--help', 'Show this message.') { puts o; exit }
+ 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.parse!
end
- end
+ end
+
+ private
+
+ def detect_ssh_connection
+ if conn = ENV['SSH_CONNECTION']
+ @host = conn.split(' ').first
+ end
+ end
end
class Command
Please sign in to comment.
Something went wrong with that request. Please try again.