mirror of
https://github.com/nishiki/manage-password.git
synced 2024-11-23 13:57:52 +00:00
add function for setup wallet config
This commit is contained in:
parent
9b853a371a
commit
ec982ce4d8
3 changed files with 34 additions and 1 deletions
9
bin/mpw
9
bin/mpw
|
@ -2,7 +2,6 @@
|
|||
# author: nishiki
|
||||
# mail: nishiki@yaegashi.fr
|
||||
|
||||
require 'rubygems'
|
||||
require 'optparse'
|
||||
require 'pathname'
|
||||
require 'locale'
|
||||
|
@ -119,6 +118,10 @@ OptionParser.new do |opts|
|
|||
opts.on('-w', '--wallet WALLET', I18n.t('option.wallet')) do |wallet|
|
||||
options[:wallet] = wallet
|
||||
end
|
||||
|
||||
opts.on('-W', '--setup-wallet', I18n.t('option.setup_wallet')) do
|
||||
options[:setup_wallet] = true
|
||||
end
|
||||
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?
|
||||
cli.import(options[:file])
|
||||
|
||||
# Setup wallet config
|
||||
elsif not options[:setup_wallet].nil?
|
||||
cli.setup_wallet_config
|
||||
|
||||
end
|
||||
|
||||
cli = nil
|
||||
|
|
|
@ -184,6 +184,12 @@ class MPW
|
|||
end
|
||||
end
|
||||
|
||||
# Set config
|
||||
# args: config -> a hash with config options
|
||||
def set_config(config)
|
||||
@config = config
|
||||
end
|
||||
|
||||
# Add a new item
|
||||
# @args: item -> Object MPW::Item
|
||||
def add(item)
|
||||
|
|
|
@ -84,6 +84,26 @@ class Cli
|
|||
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
|
||||
def decrypt
|
||||
|
|
Loading…
Reference in a new issue