mirror of
https://github.com/nishiki/manage-password.git
synced 2025-02-21 10:20:05 +00:00
remove a pub key
This commit is contained in:
parent
7759c3e1eb
commit
22239c5db4
3 changed files with 24 additions and 3 deletions
5
bin/mpw
5
bin/mpw
|
@ -161,6 +161,10 @@ elsif not options[:add].nil? and options[:key].nil?
|
||||||
elsif not options[:add].nil? and not options[:key].nil?
|
elsif not options[:add].nil? and not options[:key].nil?
|
||||||
cli.add_key(options[:key])
|
cli.add_key(options[:key])
|
||||||
|
|
||||||
|
# Delete a public key in wallet
|
||||||
|
elsif not options[:delete].nil? and not options[:key].nil?
|
||||||
|
cli.delete_key(options[:key])
|
||||||
|
|
||||||
# Export
|
# Export
|
||||||
elsif not options[:export].nil?
|
elsif not options[:export].nil?
|
||||||
cli.export(options[:export])
|
cli.export(options[:export])
|
||||||
|
@ -169,7 +173,6 @@ elsif not options[:export].nil?
|
||||||
elsif not options[:import].nil?
|
elsif not options[:import].nil?
|
||||||
cli.import(options[:import])
|
cli.import(options[:import])
|
||||||
|
|
||||||
# Interactive mode
|
|
||||||
end
|
end
|
||||||
|
|
||||||
cli = nil
|
cli = nil
|
||||||
|
|
|
@ -137,7 +137,7 @@ class MPW
|
||||||
@passwords[id] = encrypt(password)
|
@passwords[id] = encrypt(password)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Add public key
|
# Add a public key
|
||||||
# args: key -> new public key
|
# args: key -> new public key
|
||||||
def add_key(key)
|
def add_key(key)
|
||||||
data = GPGME::Key.export(key, armor: true).read
|
data = GPGME::Key.export(key, armor: true).read
|
||||||
|
@ -149,6 +149,12 @@ class MPW
|
||||||
@keys[key] = data
|
@keys[key] = data
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Delete a public key
|
||||||
|
# args: key -> public key to delete
|
||||||
|
def delete_key(key)
|
||||||
|
@keys.delete(key)
|
||||||
|
end
|
||||||
|
|
||||||
# TODO
|
# TODO
|
||||||
def check_config
|
def check_config
|
||||||
if false
|
if false
|
||||||
|
|
|
@ -186,7 +186,8 @@ class Cli
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Add new public key
|
# Add a new public key
|
||||||
|
# args: key -> the key name to add
|
||||||
def add_key(key)
|
def add_key(key)
|
||||||
@mpw.add_key(key)
|
@mpw.add_key(key)
|
||||||
@mpw.write_data
|
@mpw.write_data
|
||||||
|
@ -196,6 +197,17 @@ class Cli
|
||||||
puts "#{I18n.t('display.error')} #13: #{e}".red
|
puts "#{I18n.t('display.error')} #13: #{e}".red
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Add new public key
|
||||||
|
# args: key -> the key name to delete
|
||||||
|
def delete_key(key)
|
||||||
|
@mpw.delete_key(key)
|
||||||
|
@mpw.write_data
|
||||||
|
|
||||||
|
puts "#{I18n.t('key.delete.valid')}".green
|
||||||
|
rescue Exception => e
|
||||||
|
puts "#{I18n.t('display.error')} #15: #{e}".red
|
||||||
|
end
|
||||||
|
|
||||||
# Form to add a new item
|
# Form to add a new item
|
||||||
def add
|
def add
|
||||||
options = {}
|
options = {}
|
||||||
|
|
Loading…
Add table
Reference in a new issue