mirror of
https://github.com/nishiki/manage-password.git
synced 2024-11-26 23:33:03 +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): "
|
comment: "Enter a comment (optional): "
|
||||||
valid: "Item has been added!"
|
valid: "Item has been added!"
|
||||||
clipboard:
|
clipboard:
|
||||||
|
choice: "What do you want to copy ? [q = quit, p = password, l = login]: "
|
||||||
clean: "The clipboard has been cleaned."
|
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!"
|
password: "The password has been copied in clipboard for 30s!"
|
||||||
delete_key:
|
delete_key:
|
||||||
valid: "Key has been deleted!"
|
valid: "Key has been deleted!"
|
||||||
|
|
|
@ -77,8 +77,9 @@ fr:
|
||||||
comment: "Entrez un commentaire (optionnel): "
|
comment: "Entrez un commentaire (optionnel): "
|
||||||
valid: "L'élément a bien été ajouté!"
|
valid: "L'élément a bien été ajouté!"
|
||||||
clipboard:
|
clipboard:
|
||||||
|
choice: "Que voulez-vous copier ? [q = quitter, p = mot de passe, l = identifiant]: "
|
||||||
clean: "Le presse papier a été nettoyé."
|
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!"
|
password: "Le mot de passe a été copié dans le presse papier pour 30s!"
|
||||||
delete_key:
|
delete_key:
|
||||||
valid: "La clé a bien été supprimée!"
|
valid: "La clé a bien été supprimée!"
|
||||||
|
|
|
@ -217,20 +217,69 @@ class Cli
|
||||||
end
|
end
|
||||||
|
|
||||||
# Copy in clipboard the login and password
|
# Copy in clipboard the login and password
|
||||||
|
# @args: item -> the item
|
||||||
def clipboard(item)
|
def clipboard(item)
|
||||||
Clipboard.copy(item.user)
|
pid = nil
|
||||||
print "\n#{I18n.t('form.clipboard.login')}".green
|
|
||||||
gets
|
|
||||||
|
|
||||||
Clipboard.copy(@mpw.get_password(item.id))
|
# Security: force quit after 90s
|
||||||
puts I18n.t('form.clipboard.password').yellow
|
pid_s = Process.fork do
|
||||||
|
begin
|
||||||
|
sleep 90
|
||||||
|
Process.kill(3, Process.ppid)
|
||||||
|
rescue Interrupt
|
||||||
|
exit
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
sleep(30)
|
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
|
||||||
|
|
||||||
|
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
|
Clipboard.clear
|
||||||
puts I18n.t('form.clipboard.clean').green
|
puts I18n.t('form.clipboard.clean').green
|
||||||
|
|
||||||
rescue SystemExit, Interrupt
|
rescue SystemExit, Interrupt
|
||||||
Clipboard.clear
|
Clipboard.clear
|
||||||
|
puts I18n.t('form.clipboard.clean').green
|
||||||
|
|
||||||
|
ensure
|
||||||
|
Process.kill('HUP', pid) if not pid.nil?
|
||||||
|
Process.kill('HUP', pid_s)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Display the wallet
|
# Display the wallet
|
||||||
|
@ -259,6 +308,7 @@ class Cli
|
||||||
@wallet_file = wallets[choice-1]
|
@wallet_file = wallets[choice-1]
|
||||||
else
|
else
|
||||||
puts "#{I18n.t('display.warning')}: #{I18n.t('warning.select')}".yellow
|
puts "#{I18n.t('display.warning')}: #{I18n.t('warning.select')}".yellow
|
||||||
|
exit 2
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in a new issue