2013-08-06 20:24:09 +00:00
|
|
|
#!/usr/bin/ruby
|
|
|
|
# author: nishiki
|
|
|
|
# mail: nishiki@yaegashi.fr
|
|
|
|
# info: a simple script who manage your passwords
|
|
|
|
|
|
|
|
require 'rubygems'
|
2013-08-24 22:55:11 +00:00
|
|
|
require 'optparse'
|
2013-08-06 20:24:09 +00:00
|
|
|
require 'pathname'
|
2013-12-26 09:57:03 +00:00
|
|
|
require 'locale'
|
|
|
|
require 'i18n'
|
2013-08-06 20:24:09 +00:00
|
|
|
|
|
|
|
APP_ROOT = File.dirname(Pathname.new(__FILE__).realpath)
|
2013-09-04 17:48:06 +00:00
|
|
|
require "#{APP_ROOT}/lib/CliSSH.rb"
|
2013-08-06 20:24:09 +00:00
|
|
|
|
2013-12-26 09:57:03 +00:00
|
|
|
lang = Locale::Tag.parse(ENV['LANG']).to_simple.to_s[0..1]
|
|
|
|
|
|
|
|
if !File.exist?("#{APP_ROOT}/i18n/#{lang}.yml")
|
|
|
|
lang = 'en'
|
|
|
|
end
|
|
|
|
I18n.load_path = Dir["#{APP_ROOT}/i18n/#{lang}.yml"]
|
|
|
|
I18n.locale = lang.to_sym
|
|
|
|
|
|
|
|
cli = CliSSH.new(lang)
|
2013-08-24 22:55:11 +00:00
|
|
|
search = ARGV[0]
|
|
|
|
|
|
|
|
options = {}
|
|
|
|
OptionParser.new do |opts|
|
|
|
|
opts.banner = "Usage: mpw-ssh SEARCH [options]"
|
|
|
|
|
|
|
|
opts.on("-l", "--login LOGIN", "Force a login") do |login|
|
|
|
|
cli.login = login
|
|
|
|
end
|
|
|
|
|
|
|
|
opts.on("-p", "--port PORT", "Force a port") do |port|
|
|
|
|
cli.port = port
|
|
|
|
end
|
|
|
|
|
|
|
|
opts.on("-s", "--server SERVER", "Force a server") do |server|
|
|
|
|
cli.server = server
|
|
|
|
end
|
|
|
|
|
|
|
|
opts.on("-h", "--help", "Show this message") do |b|
|
|
|
|
puts opts
|
|
|
|
exit 0
|
|
|
|
end
|
|
|
|
end.parse!
|
|
|
|
|
|
|
|
if ARGV.length < 1
|
|
|
|
puts "Usage: mpw-ssh SEARCH [options]"
|
2013-08-06 20:24:09 +00:00
|
|
|
exit 2
|
|
|
|
end
|
|
|
|
|
|
|
|
cli.ssh(search)
|
|
|
|
|
|
|
|
exit 0
|