mirror of
https://github.com/nishiki/manage-password.git
synced 2025-03-19 21:04:35 +00:00
add question before remove, but force with option -f
This commit is contained in:
parent
13238d8d6b
commit
666a16d306
2 changed files with 23 additions and 10 deletions
12
cli.rb
12
cli.rb
|
@ -111,7 +111,16 @@ class Cli
|
|||
end
|
||||
end
|
||||
|
||||
def remove(id)
|
||||
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!"
|
||||
|
@ -122,6 +131,7 @@ class Cli
|
|||
puts "Nothing item has been removed!"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def ssh(search)
|
||||
@m.ssh(search)
|
||||
|
|
5
mpw
5
mpw
|
@ -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?
|
||||
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?
|
||||
|
|
Loading…
Add table
Reference in a new issue