Skip to content

Commit

Permalink
Adding a --host auto option in favor of --ssh.
Browse files Browse the repository at this point in the history
  • Loading branch information
JEG2 committed Oct 28, 2011
1 parent e2f42a2 commit 2810e70
Showing 1 changed file with 11 additions and 16 deletions.
27 changes: 11 additions & 16 deletions rmate
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ class Settings
@host = ENV['RMATE_HOST'].to_s if ENV.has_key? 'RMATE_HOST' @host = ENV['RMATE_HOST'].to_s if ENV.has_key? 'RMATE_HOST'
@port = ENV['RMATE_PORT'].to_i if ENV.has_key? 'RMATE_PORT' @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 @wait = false
@force = false @force = false
@verbose = false @verbose = false
Expand All @@ -33,25 +37,16 @@ class Settings


def parse_cli_options def parse_cli_options
OptionParser.new do |o| OptionParser.new do |o|
o.on( '--host=name', "Connect to host. Defaults to #{@host}.") { |v| @host = v } 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('-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('-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('-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('-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('-h', '--help', 'Show this message.') { puts o; exit } o.on_tail( '--version', 'Show version.') { puts VERSION_STRING; exit }
o.on_tail( '--version', 'Show version.') { puts VERSION_STRING; exit }
o.parse! o.parse!
end end
end end

private

def detect_ssh_connection
if conn = ENV['SSH_CONNECTION']
@host = conn.split(' ').first
end
end
end end


class Command class Command
Expand Down

0 comments on commit 2810e70

Please sign in to comment.