mirror of
https://github.com/nishiki/manage-password.git
synced 2025-03-20 21:34:35 +00:00
feat: minor improve clipboard interface
This commit is contained in:
parent
d185509113
commit
948db2e905
1 changed files with 16 additions and 8 deletions
|
@ -291,6 +291,17 @@ module MPW
|
|||
choice >= 1 && choice <= items.length ? items[choice - 1] : nil
|
||||
end
|
||||
|
||||
# Print help message for clipboard mode
|
||||
# @param item [Item]
|
||||
def clipboard_help(item)
|
||||
puts "----- #{I18n.t('form.clipboard.help.name')} -----".cyan
|
||||
puts I18n.t('form.clipboard.help.url')
|
||||
puts I18n.t('form.clipboard.help.login')
|
||||
puts I18n.t('form.clipboard.help.password')
|
||||
puts I18n.t('form.clipboard.help.otp_code') if item.otp
|
||||
puts I18n.t('form.clipboard.help.quit')
|
||||
end
|
||||
|
||||
# Copy in clipboard the login and password
|
||||
# @param item [Item]
|
||||
# @param clipboard [Boolean] enable clipboard
|
||||
|
@ -339,7 +350,10 @@ module MPW
|
|||
end
|
||||
|
||||
when 'o', 'otp'
|
||||
if clipboard
|
||||
if !item.otp
|
||||
clipboard_help(item)
|
||||
next
|
||||
elsif clipboard
|
||||
Clipboard.copy(@mpw.get_otp_code(item.id))
|
||||
else
|
||||
puts @mpw.get_otp_code(item.id)
|
||||
|
@ -347,13 +361,7 @@ module MPW
|
|||
puts I18n.t('form.clipboard.otp', time: @mpw.get_otp_remaining_time).yellow
|
||||
|
||||
else
|
||||
puts "----- #{I18n.t('form.clipboard.help.name')} -----".cyan
|
||||
puts I18n.t('form.clipboard.help.url')
|
||||
puts I18n.t('form.clipboard.help.login')
|
||||
puts I18n.t('form.clipboard.help.password')
|
||||
puts I18n.t('form.clipboard.help.otp_code')
|
||||
puts I18n.t('form.clipboard.help.quit')
|
||||
next
|
||||
clipboard_help(item)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue