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

add function for setup wallet config

This commit is contained in:
nishiki 2016-05-12 22:43:57 +02:00
parent 9b853a371a
commit ec982ce4d8
3 changed files with 34 additions and 1 deletions

View file

@ -2,7 +2,6 @@
# author: nishiki # author: nishiki
# mail: nishiki@yaegashi.fr # mail: nishiki@yaegashi.fr
require 'rubygems'
require 'optparse' require 'optparse'
require 'pathname' require 'pathname'
require 'locale' require 'locale'
@ -119,6 +118,10 @@ OptionParser.new do |opts|
opts.on('-w', '--wallet WALLET', I18n.t('option.wallet')) do |wallet| opts.on('-w', '--wallet WALLET', I18n.t('option.wallet')) do |wallet|
options[:wallet] = wallet options[:wallet] = wallet
end end
opts.on('-W', '--setup-wallet', I18n.t('option.setup_wallet')) do
options[:setup_wallet] = true
end
end.parse! end.parse!
# --------------------------------------------------------- # # --------------------------------------------------------- #
@ -177,6 +180,10 @@ elsif not options[:export].nil? and not options[:file].nil?
elsif not options[:import].nil? and not options[:file].nil? elsif not options[:import].nil? and not options[:file].nil?
cli.import(options[:file]) cli.import(options[:file])
# Setup wallet config
elsif not options[:setup_wallet].nil?
cli.setup_wallet_config
end end
cli = nil cli = nil

View file

@ -184,6 +184,12 @@ class MPW
end end
end end
# Set config
# args: config -> a hash with config options
def set_config(config)
@config = config
end
# Add a new item # Add a new item
# @args: item -> Object MPW::Item # @args: item -> Object MPW::Item
def add(item) def add(item)

View file

@ -84,6 +84,26 @@ class Cli
end end
end end
# Setup wallet config for sync
def setup_wallet_config
config = {}
config['sync'] = {}
puts I18n.t('form.setup.title')
puts '--------------------'
config['sync']['type'] = ask(I18n.t('form.setup.sync_type')).to_s
config['sync']['host'] = ask(I18n.t('form.setup.sync_host')).to_s
config['sync']['port'] = ask(I18n.t('form.setup.sync_port')).to_s
config['sync']['user'] = ask(I18n.t('form.setup.sync_user')).to_s
config['sync']['pwd'] = ask(I18n.t('form.setup.sync_pwd')).to_s
config['sync']['path'] = ask(I18n.t('form.setup.sync_path')).to_s
@mpw.set_config(config)
@mpw.write_data
rescue Exception => e
puts "#{I18n.t('display.error')} #10: #{e}".red
exit 2
end
# Request the GPG password and decrypt the file # Request the GPG password and decrypt the file
def decrypt def decrypt