1
0
Fork 0
mirror of https://github.com/nishiki/manage-password.git synced 2024-11-23 13:57:52 +00:00
mpw/mpw-ssh
2013-12-27 10:58:59 +01:00

56 lines
1.1 KiB
Ruby
Executable file

#!/usr/bin/ruby
# author: nishiki
# mail: nishiki@yaegashi.fr
# info: a simple script who manage your passwords
require 'rubygems'
require 'optparse'
require 'pathname'
require 'locale'
require 'i18n'
APP_ROOT = File.dirname(Pathname.new(__FILE__).realpath)
require "#{APP_ROOT}/lib/CliSSH.rb"
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)
options = {}
OptionParser.new do |opts|
opts.banner = "#{I18n.t('ssh.option.usage')}: mpw-ssh SEARCH [options]"
opts.on("-l", "--login LOGIN", I18n.t('ssh.option.login')) do |login|
cli.login = login
end
opts.on("-s", "--server SERVER", I18n.t('ssh.option.server')) do |server|
cli.server = server
end
opts.on("-p", "--port PORT", I18n.t('ssh.option.port')) do |port|
cli.port = port
end
opts.on("-h", "--help", I18n.t('ssh.option.help')) do |b|
puts opts
exit 0
end
end.parse!
search = ARGV[0]
if ARGV.length < 1
puts "#{I18n.t('ssh.option.usage')}: mpw-ssh SEARCH [options]"
exit 2
end
cli.ssh(search)
exit 0