Class: RemoveAction

Inherits:
BaseAction show all
Defined in:
lib/lockr/action/remove.rb

Instance Method Summary collapse

Constructor Details

#initialize(id, username, keyfile, vault) ⇒ RemoveAction

Returns a new instance of RemoveAction.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/lockr/action/remove.rb', line 5

def initialize(id,username,keyfile,vault)
  super( keyfile, vault)
  
  pwd_directory = @pwdmgr.list()
  
  unless pwd_directory.has_key?( id)
    puts "Id '#{id}' not found"
    exit 20
  end
  
  pwd_directory_id = pwd_directory[id]
  
  unless pwd_directory_id.has_key?(username)
    puts "Username '#{username}' not found for id '#{id}'"
    exit 21
  end
  
  confirm = ask( "Are you sure you want to delete the entry with id '#{id}' and username '#{username}'? (y/n)  ") { |q| }
  unless confirm.downcase == 'y'
    exit 22
  end
  
  @pwdmgr.delete( id, username)
  puts "Entry removed"
end