Sha256: 5f6fbef2eb5ef23da4737069d7e57577fec9ff9dfae54f7761d4c47441af75ee

Contents?: true

Size: 851 Bytes

Versions: 1

Compression:

Stored size: 851 Bytes

Contents

#!/usr/bin/env ruby

require 'hss'

My_Handler = HSS::Handler.new(config: ENV.fetch('HSS_CONFIG', nil))

if ARGV == ['version']
  puts HSS::VERSION
  exit
elsif ARGV == ['help'] || ARGV.empty?
  puts 'How to use:'
  puts '(what you type) -> (where it takes you)'
  My_Handler.patterns.each { |pattern| puts pattern['example'] }
  exit
end

short_host = ARGV.delete_at(ARGV.find_index { |x| x[0, 1] != '-' } || 0)
args = ARGV.reduce('') do |acc, elem|
  "#{acc} '#{elem.gsub(/([$"])/, '\1')}'"
end
command = ENV['HSS_COMMAND'] || 'ssh'
command.prepend('echo ') if ENV['HSS_DEBUG']

begin
  long_host = My_Handler.handle short_host
rescue NameError
  exec "#{ENV['HSS_PASS']} #{args} #{short_host}" if ENV.include? 'HSS_PASS'
  raise
end

$stdout.syswrite "\033]0;#{short_host}\007" if $stdout.tty? && $stdin.tty?
exec "#{command} #{long_host} #{args}"

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hss-1.1.0 bin/hss