From 8c5be6b795a784f5407e34268a39c15b151daac4 Mon Sep 17 00:00:00 2001
From: Adrien Waksberg <git@yae.im>
Date: Mon, 30 Jan 2017 22:10:56 +0100
Subject: [PATCH] wallet: add remove gpg key option

---
 bin/mpw-wallet | 18 ++++++++++++++----
 i18n/en.yml    |  3 ++-
 i18n/fr.yml    |  3 ++-
 3 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/bin/mpw-wallet b/bin/mpw-wallet
index f6ea562..8bdfb1c 100644
--- a/bin/mpw-wallet
+++ b/bin/mpw-wallet
@@ -24,9 +24,10 @@ require 'mpw/cli'
 # Options
 # --------------------------------------------------------- #
 
-options        = {}
-options[:sync] = {}
-values         = {}
+options          = {}
+options[:sync]   = {}
+options[:delete] = false
+values           = {}
 
 OptionParser.new do |opts|
 	opts.banner = "#{I18n.t('option.usage')}: mpw wallet [options]"
@@ -39,6 +40,11 @@ OptionParser.new do |opts|
 		options[:config] = config
 	end
 
+	opts.on('-d', '--delete-gpg-key NAME', I18n.t('option.delete_gpg_key')) do |gpg_key|
+		options[:gpg_key] = gpg_key
+		options[:delete]  = true
+	end
+
 	opts.on('-h', '--help', I18n.t('option.help')) do
 		puts opts
 		exit 0
@@ -89,7 +95,11 @@ cli.load_config
 if not options[:list].nil?
 	cli.list_wallet
 elsif not options[:gpg_key].nil?
-	cli.add_key(options[:gpg_key])
+	if options[:delete]
+		cli.delete_key(options[:gpg_key])
+	else
+		cli.add_key(options[:gpg_key])
+	end
 else
 	cli.get_wallet(options[:wallet])
 	cli.decrypt
diff --git a/i18n/en.yml b/i18n/en.yml
index eb45c86..6b1f23f 100644
--- a/i18n/en.yml
+++ b/i18n/en.yml
@@ -50,10 +50,11 @@ en:
 
   option:
     add: "Add an item or key"
-    add_gpg_key: "Share the wallet with an other GPG key (name or file path)"
+    add_gpg_key: "Share the wallet with an other GPG key"
     alpha: "Use letter to generate a password"
     config: "Specify the configuration file to use"
     clipboard: "Disable the clipboard feature"
+    add_gpg_key: "Delete the wallet's share with an other GPG key"
     export: "Export a wallet in an yaml file"
     file_export: "Specify the file where export data"
     file_import: "Specify the file to import"
diff --git a/i18n/fr.yml b/i18n/fr.yml
index 5a0ebc0..8dc6d21 100644
--- a/i18n/fr.yml
+++ b/i18n/fr.yml
@@ -50,10 +50,11 @@ fr:
 
   option:
     add: "Ajoute un élément ou une clé"
-    add_gpg_key: "Partage le portefeuille avec une autre clé GPG (nom ou fichier)"
+    add_gpg_key: "Partage le portefeuille avec une autre clé GPG"
     alpha: "Utilise des lettres dans la génération d'un mot de passe"
     config: "Spécifie le fichier de configuration à utiliser"
     clipboard: "Désactive la fonction presse papier"
+    delete_gpg_key: "Supprime le partage le portefeuille avec une autre clé GPG"
     export: "Exporte un portefeuille dans un fichier yaml"
     file_export: "Spécifie le fichier où exporter les données"
     file_import: "Spécifie le fichier à importer"