mirror of
https://github.com/nishiki/manage-password.git
synced 2024-11-23 05:47:53 +00:00
dynamic menu for clipboard
This commit is contained in:
parent
8a1003f1bd
commit
d55291cc14
3 changed files with 60 additions and 8 deletions
|
@ -77,8 +77,9 @@ en:
|
|||
comment: "Enter a comment (optional): "
|
||||
valid: "Item has been added!"
|
||||
clipboard:
|
||||
choice: "What do you want to copy ? [q = quit, p = password, l = login]: "
|
||||
clean: "The clipboard has been cleaned."
|
||||
login: "The login has been copied in clipboard, press any key to continue."
|
||||
login: "The login has been copied in clipboard."
|
||||
password: "The password has been copied in clipboard for 30s!"
|
||||
delete_key:
|
||||
valid: "Key has been deleted!"
|
||||
|
|
|
@ -77,8 +77,9 @@ fr:
|
|||
comment: "Entrez un commentaire (optionnel): "
|
||||
valid: "L'élément a bien été ajouté!"
|
||||
clipboard:
|
||||
choice: "Que voulez-vous copier ? [q = quitter, p = mot de passe, l = identifiant]: "
|
||||
clean: "Le presse papier a été nettoyé."
|
||||
login: "L'identifiant a été copié dans le presse papier, pressez n'importe quelle touche pour continuer."
|
||||
login: "L'identifiant a été copié dans le presse papier"
|
||||
password: "Le mot de passe a été copié dans le presse papier pour 30s!"
|
||||
delete_key:
|
||||
valid: "La clé a bien été supprimée!"
|
||||
|
|
|
@ -217,20 +217,69 @@ class Cli
|
|||
end
|
||||
|
||||
# Copy in clipboard the login and password
|
||||
# @args: item -> the item
|
||||
def clipboard(item)
|
||||
Clipboard.copy(item.user)
|
||||
print "\n#{I18n.t('form.clipboard.login')}".green
|
||||
gets
|
||||
pid = nil
|
||||
|
||||
# Security: force quit after 90s
|
||||
pid_s = Process.fork do
|
||||
begin
|
||||
sleep 90
|
||||
Process.kill(3, Process.ppid)
|
||||
rescue Interrupt
|
||||
exit
|
||||
end
|
||||
end
|
||||
|
||||
while true
|
||||
choice = ask(I18n.t('form.clipboard.choice')).to_s
|
||||
|
||||
if not pid.nil?
|
||||
Clipboard.clear
|
||||
Process.kill(9, pid)
|
||||
|
||||
pid = nil
|
||||
end
|
||||
|
||||
case choice
|
||||
when 'q', 'quit'
|
||||
break
|
||||
|
||||
when 'l', 'login'
|
||||
Clipboard.copy(item.user)
|
||||
puts I18n.t('form.clipboard.login').green
|
||||
|
||||
when 'p', 'password'
|
||||
Clipboard.copy(@mpw.get_password(item.id))
|
||||
puts I18n.t('form.clipboard.password').yellow
|
||||
|
||||
sleep(30)
|
||||
pid = Process.fork do
|
||||
begin
|
||||
sleep 30
|
||||
|
||||
Clipboard.clear
|
||||
puts I18n.t('form.clipboard.clean').green
|
||||
rescue Interrupt
|
||||
exit
|
||||
end
|
||||
end
|
||||
|
||||
else
|
||||
puts I18n.t('warning.select').yellow
|
||||
next
|
||||
end
|
||||
end
|
||||
|
||||
Clipboard.clear
|
||||
puts I18n.t('form.clipboard.clean').green
|
||||
|
||||
rescue SystemExit, Interrupt
|
||||
Clipboard.clear
|
||||
puts I18n.t('form.clipboard.clean').green
|
||||
|
||||
ensure
|
||||
Process.kill('HUP', pid) if not pid.nil?
|
||||
Process.kill('HUP', pid_s)
|
||||
end
|
||||
|
||||
# Display the wallet
|
||||
|
@ -259,6 +308,7 @@ class Cli
|
|||
@wallet_file = wallets[choice-1]
|
||||
else
|
||||
puts "#{I18n.t('display.warning')}: #{I18n.t('warning.select')}".yellow
|
||||
exit 2
|
||||
end
|
||||
end
|
||||
else
|
||||
|
|
Loading…
Reference in a new issue