1
0
Fork 0
mirror of https://github.com/nishiki/manage-password.git synced 2024-10-27 10:43:20 +00:00

replace opts by value for options to search

This commit is contained in:
Adrien Waksberg 2016-10-23 22:36:50 +02:00
parent f1f92d5658
commit 90e8b658bf

View file

@ -26,6 +26,7 @@ require 'mpw/cli'
options = {} options = {}
options[:clipboard] = true options[:clipboard] = true
values = {}
OptionParser.new do |opts| OptionParser.new do |opts|
opts.banner = "#{I18n.t('option.usage')}: mpw copy [options]" opts.banner = "#{I18n.t('option.usage')}: mpw copy [options]"
@ -39,7 +40,7 @@ OptionParser.new do |opts|
end end
opts.on('-g', '--group NAME', I18n.t('option.group')) do |group| opts.on('-g', '--group NAME', I18n.t('option.group')) do |group|
options[:group] = group values[:group] = group
end end
opts.on('-h', '--help', I18n.t('option.help')) do opts.on('-h', '--help', I18n.t('option.help')) do
@ -47,8 +48,12 @@ OptionParser.new do |opts|
exit 0 exit 0
end end
opts.on('-n', '--no-sync', I18n.t('option.no_sync')) do
options[:sync] = false
end
opts.on('-p', '--pattern PATTERN', I18n.t('option.pattern')) do |pattern| opts.on('-p', '--pattern PATTERN', I18n.t('option.pattern')) do |pattern|
options[:pattern] = pattern values[:pattern] = pattern
end end
opts.on('-w', '--wallet NAME', I18n.t('option.wallet')) do |wallet| opts.on('-w', '--wallet NAME', I18n.t('option.wallet')) do |wallet|
@ -59,11 +64,7 @@ end.parse!
config = MPW::Config.new(options[:config]) config = MPW::Config.new(options[:config])
cli = MPW::Cli.new(config, options[:sync]) cli = MPW::Cli.new(config, options[:sync])
opts = { search: options[:pattern],
group: options[:group],
}
cli.load_config cli.load_config
cli.get_wallet(options[:wallet]) cli.get_wallet(options[:wallet])
cli.decrypt cli.decrypt
cli.copy(options[:clipboard], opts) cli.copy(options[:clipboard], values)