1
0
Fork 0
mirror of https://github.com/nishiki/manage-password.git synced 2025-02-22 10:50:10 +00:00
mpw/bin/mpw

70 lines
2.3 KiB
Text
Raw Normal View History

2013-07-16 19:42:49 +02:00
#!/usr/bin/ruby
2016-06-30 22:02:45 +02:00
# MPW is a software to crypt and manage your passwords
# Copyright (C) 2016 Adrien Waksberg <mpw@yae.im>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
2013-07-16 19:42:49 +02:00
2016-07-10 18:55:18 +02:00
$: << File.expand_path('../../lib', __FILE__)
2013-12-25 18:51:41 +01:00
require 'locale'
2014-11-15 19:14:42 +01:00
require 'set'
2013-12-25 18:51:41 +01:00
require 'i18n'
require 'colorize'
2013-07-16 19:57:48 +02:00
2014-02-01 20:17:55 +01:00
# --------------------------------------------------------- #
# Set local
# --------------------------------------------------------- #
2013-12-26 10:47:54 +01:00
lang = Locale::Tag.parse(ENV['LANG']).to_simple.to_s[0..1]
2013-12-25 18:51:41 +01:00
2014-11-16 19:39:38 +01:00
if defined?(I18n.enforce_available_locales)
2014-02-01 20:17:55 +01:00
I18n.enforce_available_locales = true
end
2013-12-30 22:14:29 +01:00
I18n::Backend::Simple.send(:include, I18n::Backend::Fallbacks)
2016-07-10 18:55:18 +02:00
I18n.load_path = Dir["#{File.expand_path('../../i18n', __FILE__)}/*.yml"]
2013-12-30 22:14:29 +01:00
I18n.default_locale = :en
2014-11-16 19:39:38 +01:00
I18n.locale = lang.to_sym
2013-12-25 18:51:41 +01:00
2014-02-01 20:17:55 +01:00
# --------------------------------------------------------- #
# Options
# --------------------------------------------------------- #
2016-10-12 23:23:03 +02:00
bin_dir = File.dirname(__FILE__)
command = "#{bin_dir}/mpw-#{ARGV[0]}"
2016-10-12 23:23:03 +02:00
if Dir.glob("#{bin_dir}/mpw-*").include?("#{command}")
begin
Kernel.load(command)
2017-02-21 22:38:55 +01:00
rescue OptionParser::ParseError => e
puts "#{I18n.t('display.error')}: #{e}".red
end
2016-11-05 15:34:11 +01:00
else
puts "#{I18n.t('option.usage')}: mpw COMMAND [options]\n\n"
puts 'Commands:'
puts " add #{I18n.t('command.add')}"
puts " config #{I18n.t('command.config')}"
puts " copy #{I18n.t('command.copy')}"
puts " delete #{I18n.t('command.delete')}"
puts " export #{I18n.t('command.export')}"
puts " genpwd #{I18n.t('command.genpwd')}"
puts " import #{I18n.t('command.import')}"
puts " list #{I18n.t('command.list')}"
puts " update #{I18n.t('command.update')}"
puts " wallet #{I18n.t('command.wallet')}"
exit 3
2013-07-16 19:42:49 +02:00
end