1
0
Fork 0
mirror of https://github.com/nishiki/manage-password.git synced 2024-11-26 23:33:03 +00:00

rename function checkconfig to is_valid?

This commit is contained in:
nishiki 2016-05-16 20:15:42 +02:00
parent f842bd63ee
commit 2a0decd215
3 changed files with 12 additions and 12 deletions

View file

@ -128,13 +128,11 @@ end.parse!
# Main
# --------------------------------------------------------- #
config = MPW::Config.new(options[:config])
check_error = config.checkconfig
cli = MPW::Cli.new(config)
config = MPW::Config.new(options[:config])
cli = MPW::Cli.new(config)
# Setup a new config
if not check_error or not options[:setup].nil?
if not config.is_valid? or not options[:setup].nil?
cli.setup(lang)
elsif not config.check_gpg_key?
cli.setup_gpg_key

View file

@ -98,18 +98,19 @@ class Config
# Check the config file
# @rtrn: true if the config file is correct
def checkconfig
def is_valid?
config = YAML::load_file(@config_file)
@key = config['config']['key']
@lang = config['config']['lang']
@wallet_dir = config['config']['wallet_dir']
if @key.empty? or @wallet_dir.empty?
raise I18n.t('error.config.check')
end
raise if @key.empty? or @wallet_dir.empty?
I18n.locale = @lang.to_sym
rescue Exception => e
raise "#{I18n.t('error.config.check')}\n#{e}"
return true
rescue
return false
end
# Check if private key exist

View file

@ -35,7 +35,8 @@ class Cli
I18n.locale = language.to_sym
@config.setup(key, lang, wallet_dir)
@config.checkconfig
raise I18n.t('error.config.check') if not @config.is_valid?
puts "#{I18n.t('form.setup_config.valid')}".green
rescue Exception => e