diff --git a/bin/mpw-wallet b/bin/mpw-wallet index 5222d81..221bb38 100644 --- a/bin/mpw-wallet +++ b/bin/mpw-wallet @@ -54,10 +54,14 @@ OptionParser.new do |opts| values[:host] = host end - opts.on('-l', '--list', I18n.t('option.list')) do |list| + opts.on('-l', '--list', I18n.t('option.list')) do options[:list] = true end + opts.on('-L', '--list-keys', I18n.t('option.list_keys')) do + options[:list_keys] = true + end + opts.on('-n', '--no-sync', I18n.t('option.no_sync')) do options[:sync] = false end @@ -98,7 +102,9 @@ else cli.get_wallet(options[:wallet]) cli.decrypt - if not options[:gpg_key].nil? + if not options[:list_keys].nil? + cli.list_keys + elsif not options[:gpg_key].nil? if options[:delete] cli.delete_key(options[:gpg_key]) else diff --git a/i18n/en.yml b/i18n/en.yml index 16a8c69..abf32bd 100644 --- a/i18n/en.yml +++ b/i18n/en.yml @@ -71,6 +71,7 @@ en: lang: "Set the software language" length: "Size of the password" list: "List the wallets" + list_keys: "List the GPG keys in wallet" no_sync: "Disable synchronization with the server" numeric: "Use number to generate a password" password: "Change the password for the synchronization" @@ -173,6 +174,7 @@ en: display: comment: "Comment" error: "ERROR" + keys: "GPG keys" gpg_password: "GPG passphrase: " group: "Group" login: "Login" diff --git a/i18n/fr.yml b/i18n/fr.yml index 0e4e9f6..9b6a1ea 100644 --- a/i18n/fr.yml +++ b/i18n/fr.yml @@ -71,6 +71,7 @@ fr: lang: "Spécifie la langue du logiciel (ex: fr)" length: "Taille du mot de passe" list: "Liste les portefeuilles" + list_keys: "Liste les clés GPG dans le portefeuille" no_sync: "Désactive la synchronisation avec le serveur" numeric: "Utilise des chiffre dans la génération d'un mot de passe" password: "Changer le mot de passe de connexion" @@ -173,6 +174,7 @@ fr: display: comment: "Commentaire" error: "ERREUR" + keys: "Clés GPG" gpg_password: "Mot de passe GPG: " group: "Groupe" login: "Identifiant" diff --git a/lib/mpw/cli.rb b/lib/mpw/cli.rb index 09e3ebd..15915af 100644 --- a/lib/mpw/cli.rb +++ b/lib/mpw/cli.rb @@ -112,6 +112,30 @@ class Cli exit 2 end + # List gpg keys in wallet + def list_keys + i = 1 + length = 0 + + @mpw.list_keys.each do |key| + length = key.length if length < key.length + end + length += 7 + + puts "\n#{I18n.t('display.keys')}".red + length.times { print '=' } + print "\n" + + @mpw.list_keys.each do |key| + print " #{i}".cyan + (3 - i.to_s.length).times { print ' ' } + puts "| #{key}" + i += 1 + end + + print "\n" + end + # Load config def load_config @config.load_config