mirror of
https://github.com/nishiki/manage-password.git
synced 2024-11-27 07:33:05 +00:00
add option for choice the wallet
This commit is contained in:
parent
163ef46076
commit
afb197aff5
2 changed files with 8 additions and 3 deletions
7
bin/mpw
7
bin/mpw
|
@ -41,6 +41,7 @@ options[:format] = false
|
||||||
options[:sync] = true
|
options[:sync] = true
|
||||||
options[:group] = nil
|
options[:group] = nil
|
||||||
options[:config] = nil
|
options[:config] = nil
|
||||||
|
options[:wallet] = nil
|
||||||
|
|
||||||
OptionParser.new do |opts|
|
OptionParser.new do |opts|
|
||||||
opts.banner = "#{I18n.t('option.usage')}: mpw [options]"
|
opts.banner = "#{I18n.t('option.usage')}: mpw [options]"
|
||||||
|
@ -90,6 +91,10 @@ OptionParser.new do |opts|
|
||||||
options[:sync] = false
|
options[:sync] = false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
opts.on('-w', '--wallet WALLET', I18n.t('option.wallet')) do |wallet|
|
||||||
|
options[:wallet] = wallet
|
||||||
|
end
|
||||||
|
|
||||||
opts.on('-G', '--generate-password [LENGTH]', I18n.t('option.generate_password')) do |length|
|
opts.on('-G', '--generate-password [LENGTH]', I18n.t('option.generate_password')) do |length|
|
||||||
puts MPW::MPW::password(length)
|
puts MPW::MPW::password(length)
|
||||||
exit 0
|
exit 0
|
||||||
|
@ -108,7 +113,7 @@ end.parse!
|
||||||
config = MPW::Config.new(options[:config])
|
config = MPW::Config.new(options[:config])
|
||||||
check_error = config.checkconfig
|
check_error = config.checkconfig
|
||||||
|
|
||||||
cli = Cli.new(config)
|
cli = Cli.new(config, options[:wallet])
|
||||||
|
|
||||||
# Setup a new config
|
# Setup a new config
|
||||||
if not check_error or not options[:setup].nil?
|
if not check_error or not options[:setup].nil?
|
||||||
|
|
|
@ -17,9 +17,9 @@ class Cli
|
||||||
# @args: lang -> the operating system language
|
# @args: lang -> the operating system language
|
||||||
# config_file -> a specify config file
|
# config_file -> a specify config file
|
||||||
# TODO
|
# TODO
|
||||||
def initialize(config)
|
def initialize(config, wallet)
|
||||||
@config = config
|
@config = config
|
||||||
@wallet_file = "#{@config.wallet_dir}/test.mpw"
|
@wallet_file = "#{@config.wallet_dir}/#{wallet}.mpw"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Create a new config file
|
# Create a new config file
|
||||||
|
|
Loading…
Reference in a new issue