1
0
Fork 0
mirror of https://github.com/nishiki/manage-password.git synced 2025-03-19 12:59:30 +00:00

add question before remove, but force with option -f

This commit is contained in:
nishiki 2013-07-17 23:19:35 +02:00
parent 13238d8d6b
commit 666a16d306
2 changed files with 23 additions and 10 deletions

26
cli.rb
View file

@ -111,15 +111,25 @@ class Cli
end
end
def remove(id)
if @m.remove(id)
if @m.encrypt()
puts "The item #{id} has been removed!"
else
puts "ERROR: #{@m.error_msg}"
def remove(id, force=false)
if not force
confirm = ask("Are you sur to remove the item: #{id} ? (y/N) ")
if confirm =~ /^(y|yes|YES|Yes|Y)$/
force = true
end
end
if force
if @m.remove(id)
if @m.encrypt()
puts "The item #{id} has been removed!"
else
puts "ERROR: #{@m.error_msg}"
end
else
puts "Nothing item has been removed!"
end
else
puts "Nothing item has been removed!"
end
end

7
mpw
View file

@ -52,7 +52,6 @@ end.parse!
cli = Cli.new()
puts options
# Display the item's informations
if not options[:display].nil?
if not options[:type].nil?
@ -65,7 +64,11 @@ if not options[:display].nil?
# Remove an item
elsif not options[:remove].nil?
cli.remove(options[:remove])
if not options[:force].nil?
cli.remove(options[:remove], options[:force])
else
cli.remove(options[:remove])
end
# Update an item
elsif not options[:update].nil?