mirror of
https://github.com/nishiki/manage-password.git
synced 2025-02-20 01:50:04 +00:00
catch backstrace when interrupt
This commit is contained in:
parent
50ea811b61
commit
4502c43424
1 changed files with 61 additions and 56 deletions
117
bin/mpw
117
bin/mpw
|
@ -142,61 +142,66 @@ end.parse!
|
||||||
# Main
|
# Main
|
||||||
# --------------------------------------------------------- #
|
# --------------------------------------------------------- #
|
||||||
|
|
||||||
config = MPW::Config.new(options[:config])
|
begin
|
||||||
cli = MPW::Cli.new(config, options[:sync])
|
config = MPW::Config.new(options[:config])
|
||||||
|
cli = MPW::Cli.new(config, options[:sync])
|
||||||
|
|
||||||
|
# Setup a new config
|
||||||
|
if not config.is_valid? or not options[:setup].nil?
|
||||||
|
cli.setup(lang)
|
||||||
|
elsif not config.check_gpg_key?
|
||||||
|
cli.setup_gpg_key
|
||||||
|
end
|
||||||
|
|
||||||
# Setup a new config
|
cli.get_wallet(options[:wallet])
|
||||||
if not config.is_valid? or not options[:setup].nil?
|
cli.decrypt
|
||||||
cli.setup(lang)
|
|
||||||
elsif not config.check_gpg_key?
|
# Display the item's informations
|
||||||
cli.setup_gpg_key
|
if not options[:show].nil?
|
||||||
|
opts = {search: options[:show],
|
||||||
|
group: options[:group],
|
||||||
|
}
|
||||||
|
|
||||||
|
cli.display(opts)
|
||||||
|
|
||||||
|
# Remove an item
|
||||||
|
elsif not options[:delete].nil? and not options[:id].nil?
|
||||||
|
cli.delete(options[:id], options[:force])
|
||||||
|
|
||||||
|
# Update an item
|
||||||
|
elsif not options[:update].nil? and not options[:id].nil?
|
||||||
|
cli.update(options[:id])
|
||||||
|
|
||||||
|
# Add a new item
|
||||||
|
elsif not options[:add].nil? and options[:key].nil?
|
||||||
|
cli.add
|
||||||
|
|
||||||
|
# Add a new public key in wallet
|
||||||
|
elsif not options[:add].nil? and not options[:key].nil?
|
||||||
|
cli.add_key(options[:key], options[:file])
|
||||||
|
|
||||||
|
# Delete a public key in wallet
|
||||||
|
elsif not options[:delete].nil? and not options[:key].nil?
|
||||||
|
cli.delete_key(options[:key])
|
||||||
|
|
||||||
|
# Export
|
||||||
|
elsif not options[:export].nil? and not options[:file].nil?
|
||||||
|
cli.export(options[:file])
|
||||||
|
|
||||||
|
# Add a new item
|
||||||
|
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
|
||||||
|
|
||||||
|
exit 0
|
||||||
|
|
||||||
|
rescue SystemExit, Interrupt
|
||||||
|
exit 3
|
||||||
end
|
end
|
||||||
|
|
||||||
cli.get_wallet(options[:wallet])
|
|
||||||
cli.decrypt
|
|
||||||
|
|
||||||
# Display the item's informations
|
|
||||||
if not options[:show].nil?
|
|
||||||
opts = {search: options[:show],
|
|
||||||
group: options[:group],
|
|
||||||
}
|
|
||||||
|
|
||||||
cli.display(opts)
|
|
||||||
|
|
||||||
# Remove an item
|
|
||||||
elsif not options[:delete].nil? and not options[:id].nil?
|
|
||||||
cli.delete(options[:id], options[:force])
|
|
||||||
|
|
||||||
# Update an item
|
|
||||||
elsif not options[:update].nil? and not options[:id].nil?
|
|
||||||
cli.update(options[:id])
|
|
||||||
|
|
||||||
# Add a new item
|
|
||||||
elsif not options[:add].nil? and options[:key].nil?
|
|
||||||
cli.add
|
|
||||||
|
|
||||||
# Add a new public key in wallet
|
|
||||||
elsif not options[:add].nil? and not options[:key].nil?
|
|
||||||
cli.add_key(options[:key], options[:file])
|
|
||||||
|
|
||||||
# Delete a public key in wallet
|
|
||||||
elsif not options[:delete].nil? and not options[:key].nil?
|
|
||||||
cli.delete_key(options[:key])
|
|
||||||
|
|
||||||
# Export
|
|
||||||
elsif not options[:export].nil? and not options[:file].nil?
|
|
||||||
cli.export(options[:file])
|
|
||||||
|
|
||||||
# Add a new item
|
|
||||||
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
|
|
||||||
|
|
||||||
exit 0
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue