mirror of
https://github.com/nishiki/manage-password.git
synced 2025-02-21 10:20:05 +00:00
cli: fix delete function
This commit is contained in:
parent
38beb7ad53
commit
163ef46076
1 changed files with 16 additions and 19 deletions
|
@ -213,31 +213,28 @@ class Cli
|
||||||
# @args: id -> the item's id
|
# @args: id -> the item's id
|
||||||
# force -> no resquest a validation
|
# force -> no resquest a validation
|
||||||
def delete(id, force=false)
|
def delete(id, force=false)
|
||||||
|
item = @mpw.search_by_id(id)
|
||||||
|
|
||||||
|
if item.nil?
|
||||||
|
puts I18n.t('display.nothing')
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
if not force
|
if not force
|
||||||
item = @mpw.search_by_id(id)
|
display_item(item)
|
||||||
|
|
||||||
if not item.nil?
|
confirm = ask("#{I18n.t('form.delete.ask', id: id)} (y/N) ").to_s
|
||||||
display_item(item)
|
if not confirm =~ /^(y|yes|YES|Yes|Y)$/
|
||||||
|
return
|
||||||
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')
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if force
|
item.delete
|
||||||
item.delete
|
@mpw.write_data
|
||||||
|
|
||||||
if @mpw.encrypt
|
puts "#{I18n.t('form.delete.valid', id: id)}".green
|
||||||
sync
|
rescue
|
||||||
puts "#{I18n.t('form.delete.valid', id: id)}".green
|
puts "#{I18n.t('display.error')} #16: #{@mpw.error_msg}".red
|
||||||
else
|
|
||||||
puts "#{I18n.t('display.error')} #16: #{@mpw.error_msg}".red
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Export the items in a CSV file
|
# Export the items in a CSV file
|
||||||
|
|
Loading…
Add table
Reference in a new issue