mirror of
https://github.com/nishiki/manage-password.git
synced 2025-03-19 12:59:30 +00:00
replace opts by value for options to search
This commit is contained in:
parent
6d2a45217c
commit
f1f92d5658
5 changed files with 17 additions and 29 deletions
|
@ -25,6 +25,7 @@ require 'mpw/cli'
|
||||||
# --------------------------------------------------------- #
|
# --------------------------------------------------------- #
|
||||||
|
|
||||||
options = {}
|
options = {}
|
||||||
|
values = {}
|
||||||
|
|
||||||
OptionParser.new do |opts|
|
OptionParser.new do |opts|
|
||||||
opts.banner = "#{I18n.t('option.usage')}: mpw delete [options]"
|
opts.banner = "#{I18n.t('option.usage')}: mpw delete [options]"
|
||||||
|
@ -34,7 +35,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
|
||||||
|
@ -43,7 +44,7 @@ OptionParser.new do |opts|
|
||||||
end
|
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|
|
||||||
|
@ -54,11 +55,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.delete(opts)
|
cli.delete(values)
|
||||||
|
|
|
@ -25,6 +25,7 @@ require 'mpw/cli'
|
||||||
# --------------------------------------------------------- #
|
# --------------------------------------------------------- #
|
||||||
|
|
||||||
options = {}
|
options = {}
|
||||||
|
values = {}
|
||||||
|
|
||||||
OptionParser.new do |opts|
|
OptionParser.new do |opts|
|
||||||
opts.banner = "#{I18n.t('option.usage')}: mpw wallet [options]"
|
opts.banner = "#{I18n.t('option.usage')}: mpw wallet [options]"
|
||||||
|
@ -38,7 +39,7 @@ OptionParser.new do |opts|
|
||||||
end
|
end
|
||||||
|
|
||||||
opts.on('-g', '--group GROUP', I18n.t('option.group')) do |group|
|
opts.on('-g', '--group GROUP', 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,7 +48,7 @@ OptionParser.new do |opts|
|
||||||
end
|
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|
|
||||||
|
@ -58,11 +59,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.export(options[:file], opts)
|
cli.export(options[:file], values)
|
||||||
|
|
11
bin/mpw-list
11
bin/mpw-list
|
@ -25,6 +25,7 @@ require 'mpw/cli'
|
||||||
# --------------------------------------------------------- #
|
# --------------------------------------------------------- #
|
||||||
|
|
||||||
options = {}
|
options = {}
|
||||||
|
values = {}
|
||||||
|
|
||||||
OptionParser.new do |opts|
|
OptionParser.new do |opts|
|
||||||
opts.banner = "#{I18n.t('option.usage')}: mpw list [options]"
|
opts.banner = "#{I18n.t('option.usage')}: mpw list [options]"
|
||||||
|
@ -34,7 +35,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
|
||||||
|
@ -43,7 +44,7 @@ OptionParser.new do |opts|
|
||||||
end
|
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|
|
||||||
|
@ -54,11 +55,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.list(opts)
|
cli.list(values)
|
||||||
|
|
|
@ -25,6 +25,7 @@ require 'mpw/cli'
|
||||||
# --------------------------------------------------------- #
|
# --------------------------------------------------------- #
|
||||||
|
|
||||||
options = {}
|
options = {}
|
||||||
|
values = {}
|
||||||
|
|
||||||
OptionParser.new do |opts|
|
OptionParser.new do |opts|
|
||||||
opts.banner = "#{I18n.t('option.usage')}: mpw update [options]"
|
opts.banner = "#{I18n.t('option.usage')}: mpw update [options]"
|
||||||
|
@ -34,7 +35,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
|
||||||
|
@ -43,7 +44,7 @@ OptionParser.new do |opts|
|
||||||
end
|
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|
|
||||||
|
@ -54,11 +55,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.update(opts)
|
cli.update(values)
|
||||||
|
|
|
@ -240,7 +240,7 @@ class MPW
|
||||||
def list(options={})
|
def list(options={})
|
||||||
result = []
|
result = []
|
||||||
|
|
||||||
search = options[:search].to_s.downcase
|
search = options[:pattern].to_s.downcase
|
||||||
group = options[:group].to_s.downcase
|
group = options[:group].to_s.downcase
|
||||||
|
|
||||||
@data.each do |item|
|
@data.each do |item|
|
||||||
|
|
Loading…
Add table
Reference in a new issue