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

cli: fix delete function

This commit is contained in:
nishiki 2016-05-05 23:24:08 +02:00
parent 38beb7ad53
commit 163ef46076

View file

@ -213,32 +213,29 @@ class Cli
# @args: id -> the item's id
# force -> no resquest a validation
def delete(id, force=false)
if not force
item = @mpw.search_by_id(id)
if not item.nil?
if item.nil?
puts I18n.t('display.nothing')
return
end
if not force
display_item(item)
confirm = ask("#{I18n.t('form.delete.ask', id: id)} (y/N) ").to_s
if confirm =~ /^(y|yes|YES|Yes|Y)$/
force = true
end
else
puts I18n.t('display.nothing')
if not confirm =~ /^(y|yes|YES|Yes|Y)$/
return
end
end
if force
item.delete
@mpw.write_data
if @mpw.encrypt
sync
puts "#{I18n.t('form.delete.valid', id: id)}".green
else
rescue
puts "#{I18n.t('display.error')} #16: #{@mpw.error_msg}".red
end
end
end
# Export the items in a CSV file
# @args: file -> the destination file