lib/ssh/manager/client.rb in ssh-manager-1.1.0 vs lib/ssh/manager/client.rb in ssh-manager-1.1.1
- old
+ new
@@ -7,17 +7,20 @@
module SSH
module Manager
class Client
attr_accessor :options
+ CODES = %w[iso-2022-jp shift_jis euc-jp utf8 binary]
+ CODE_ALIASES = { "jis" => "iso-2022-jp", "sjis" => "shift_jis" }
def initialize(argv)
@options = {}
@argv = argv
extract_options
end
+
def execute!
cli = SSH::Manager::Cli
# TODO id.to_i is not good enough. we want to support hostnames too
# Checking and casting in the methods itself could solve the problem
# futhermore this could reside in a separate method
@@ -52,18 +55,25 @@
puts 'Connecting to multiple ips..'
cli.new(@options).multiple_connection(@options[:multi])
elsif @options[:transfer_key]
puts 'Transfering key..'
cli.new(@options).transfer_key(@options[:transfer_key].to_i)
+ elsif @options[:codeing]
+ puts 'coding key..'
+ cli.new(@options).test(@options[:coding].to_i)
elsif @options[:search]
puts 'Searching ..'
cli.new(@options).search_for(@options[:search])
# elsif @options[:settings]
# puts 'Settings'
# cli.new(@options).settings(@options[:settings])
else
- cli.new(@argv.first).connect_to(@argv.first) if @argv != []
+ if @argv.count == 1
+ cli.new(@options).connect_to(@argv.first.split(',')) if @argv != []
+ else
+ cli.new(@options).connect_to(@argv) if @argv != []
+ end
puts @optparse if @argv ==[]
exit
end
end
@@ -79,9 +89,13 @@
@options[:transfer_key] = opt
end
@options[:transfer_file] = false
opts.on( '-r', '--transferfile filename', 'file or dir / connection_ID / dest_path(default is /home/user/)' ) do |opt|
@options[:transfer_file] = opt
+ end
+ code_list = (CODE_ALIASES.keys + CODES).join(',')
+ opts.on("--code CODE", CODES, CODE_ALIASES, "Select encoding"," (#{code_list})") do |encoding|
+ options.encoding = encoding
end
@options[:connect] = false
opts.on( '-c', '--connect x y z', Array, 'connect to <ids>' ) do |opt|
@options[:connect] = opt
end