From ba297c3d7db6046b7796397d45502b1bf2e4326d Mon Sep 17 00:00:00 2001 From: nishiki Date: Tue, 18 Mar 2014 21:08:09 +0100 Subject: [PATCH] ask if you want create gpg key --- MPW/Config.rb | 5 +++++ MPW/UI/Cli.rb | 7 +++++++ i18n/cli/en.yml | 2 ++ i18n/cli/fr.yml | 2 ++ 4 files changed, 16 insertions(+) diff --git a/MPW/Config.rb b/MPW/Config.rb index 42a840d..fadfbff 100644 --- a/MPW/Config.rb +++ b/MPW/Config.rb @@ -99,6 +99,11 @@ module MPW end # Setup a new gpg key + # @args: password -> the GPG key password + # name -> the name of user + # length -> length of the GPG key + # expire -> the time of expire to GPG key + # @rtrn: true if the GPG key is create, else false def setup_gpg_key(password, name, length = 2048, expire = 0) if name.nil? || name.empty? @error_msg = "#{I18n.t('error.config.genkey_gpg.name')}" diff --git a/MPW/UI/Cli.rb b/MPW/UI/Cli.rb index 050e0d4..baf522e 100644 --- a/MPW/UI/Cli.rb +++ b/MPW/UI/Cli.rb @@ -118,6 +118,13 @@ class Cli def setup_gpg_key puts I18n.t('form.setup_gpg_key.title') puts '--------------------' + ask = ask(I18n.t('form.setup_gpg_key.ask')).to_s + + if !['Y', 'y', 'O', 'o'].include?(ask) + puts I18n.t('form.setup_gpg_key.no_create') + exit 2 + end + name = ask(I18n.t('form.setup_gpg_key.name')).to_s password = ask(I18n.t('form.setup_gpg_key.password')).to_s length = ask(I18n.t('form.setup_gpg_key.length')).to_s diff --git a/i18n/cli/en.yml b/i18n/cli/en.yml index dd58ab0..61df851 100644 --- a/i18n/cli/en.yml +++ b/i18n/cli/en.yml @@ -83,6 +83,8 @@ en: valid: "The config file has been created!" setup_gpg_key: title: "Setup a GPG key" + ask: "Do you want create your GPG key ? (Y/n)" + no_create: "You must create manually your GPG key or relaunch the software." name: "Your name and lastname: " password: "A password for the GPG key: " length: "Size of the GPG key [default=2048]: " diff --git a/i18n/cli/fr.yml b/i18n/cli/fr.yml index e38e00d..cc2a982 100644 --- a/i18n/cli/fr.yml +++ b/i18n/cli/fr.yml @@ -83,6 +83,8 @@ fr: valid: "Le fichier de configuration a bien été créé!" setup_gpg_key: title: "Configuration d'une clé GPG" + ask: "Voulez vous créer votre clé GPG ? (O/n)" + no_create: "Veuillez créer manuellement votre clé GPG ou relancer le logiciel." name: "Votre nom et prénom: " password: "Mot de passe de la clé GPG: " length: "Taille de la clé GPG [défaut=2048]: "