lib/ssh/manager/client.rb in ssh-manager-1.1.1 vs lib/ssh/manager/client.rb in ssh-manager-1.1.2

- old
+ new

@@ -31,10 +31,13 @@ puts 'Connecting ..' cli.new(@options).connect_to(@options[:connect]) elsif @options[:info] puts 'Printing info ..' cli.new(@options).show_info(@options[:info]) + elsif @options[:execute] + puts 'Executing command..' + cli.new(@options).execute_command(@options[:execute]) elsif @options[:transfer_file] puts 'Transfering file..' cli.new(@options).transfer_file(@options[:transfer_file].to_i, @argv[2], @argv[3]) elsif @options[:ping] puts 'Pinging..' @@ -48,26 +51,26 @@ elsif @options[:upgrade] puts 'Checking for new updates ..' cli.new(@options).update_available elsif @options[:update] puts 'Updating ..' - cli.new(@options).update(@options[:update].to_i) + cli.new(@options).update(@options[:update]) elsif @options[:multi] 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] + cli.new(@options).transfer_key(@options[:transfer_key]) + elsif @options[:encoding] puts 'coding key..' - cli.new(@options).test(@options[:coding].to_i) + cli.new(@options).test(@options[:encoding].to_i) + elsif @options[:settings] + puts 'Settings' + cli.new(@options).settings elsif @options[:search] puts 'Searching ..' cli.new(@options).search_for(@options[:search]) - # elsif @options[:settings] - # puts 'Settings' - # cli.new(@options).settings(@options[:settings]) else if @argv.count == 1 cli.new(@options).connect_to(@argv.first.split(',')) if @argv != [] else cli.new(@options).connect_to(@argv) if @argv != [] @@ -76,73 +79,86 @@ exit end end def extract_options + begin @optparse = OptionParser.new do |opts| opts.banner = "Usage: sshm [options] ..." @options[:add] = false opts.on( '-a', '--add', 'add a new connection' ) do @options[:add] = true end @options[:transfer_key] = false - opts.on( '-t', '--transferkey id', 'transfer key to <id>' ) do |opt| + opts.on( '-t', '--transferkey id,id,id', Array, 'transfer key to <id>' ) do |opt| @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 + @options[:encoding] = false code_list = (CODE_ALIASES.keys + CODES).join(',') opts.on("--code CODE", CODES, CODE_ALIASES, "Select encoding"," (#{code_list})") do |encoding| - options.encoding = encoding + @options[:encoding] = encoding end @options[:connect] = false - opts.on( '-c', '--connect x y z', Array, 'connect to <ids>' ) do |opt| + opts.on( '-c', '--connect id1, id2, id3', Array, 'connect to <ids>' ) do |opt| @options[:connect] = opt end @options[:info] = false opts.on( '-i', '--info id1 id2 id3',Array, 'info about to <id>' ) do |opt| @options[:info] = opt end + @options[:execute] = false + opts.on( '-x', '--exec id1 id2 id3',Array, 'exec command on <id>' ) do |opt| + @options[:execute] = opt + end @options[:ping] = false opts.on( '-p', '--ping id', 'test connection of <id>' ) do |opt| @options[:ping] = opt end @options[:delete] = false opts.on( '-d', '--delete id1 id2 id3',Array, 'delete connection <ids>' ) do |opt| @options[:delete] = opt end @options[:update] = false - opts.on( '-u', '--update id', 'update connection <id>' ) do |opt| + opts.on( '-u', '--update id,id,id',Array ,'update connection <id>' ) do |opt| @options[:update] = opt end @options[:search] = false opts.on( '-s', '--search string', 'search connection for given criteria' ) do |opt| @options[:search] = opt end @options[:multi] = false - opts.on( '-m', '--multi string', 'connect to multiple ips with given criteria' ) do |opt| + opts.on( '-m', '--multi searchterm', 'connect to multiple ips with given criteria' ) do |opt| @options[:multi] = opt end @options[:list] = false opts.on( '-l', '--list', 'list all connections' ) do @options[:list] = true end @options[:upgrade] = false opts.on( '-g', '--upgrade', 'checks for upgrade' ) do @options[:upgrade] = true end + @options[:settings] = false + opts.on( '--settings', 'update settings' ) do + @options[:settings] = true + end opts.on( '-h', '--help', 'display this screen' ) do puts opts exit end opts.on( '-v', '--version', 'print programs version' ) do puts SSH::Manager::VERSION exit end end @optparse.parse(@argv) + rescue => e + catch "That didnt work: #{e.to_s}" + end end end end end