diff --git a/bin/mpw-wallet b/bin/mpw-wallet index 6518283..ea40de2 100644 --- a/bin/mpw-wallet +++ b/bin/mpw-wallet @@ -55,14 +55,6 @@ OptionParser.new do |opts| options[:list_keys] = true end - opts.on('-p', '--path PATH', I18n.t('option.path')) do |path| - options[:path] = path - end - - opts.on('-P', '--default-path', I18n.t('option.default_path')) do - options[:path] = 'default' - end - opts.on('-w', '--wallet NAME', I18n.t('option.wallet')) do |wallet| options[:wallet] = wallet end @@ -73,10 +65,7 @@ cli = MPW::Cli.new(config) cli.load_config -if options.key?(:path) - cli.get_wallet(options[:wallet]) - cli.set_wallet_path(options[:path]) -elsif options.key?(:list_keys) || options.key?(:gpg_key) +if options.key?(:list_keys) || options.key?(:gpg_key) cli.get_wallet(options[:wallet]) cli.decrypt diff --git a/i18n/en.yml b/i18n/en.yml index 9df7bda..36eb7b3 100644 --- a/i18n/en.yml +++ b/i18n/en.yml @@ -46,7 +46,6 @@ en: comment: "Specify a comment" config: "Specify the configuration file to use" clipboard: "Disable the clipboard feature" - default_path: "Move the wallet to the default directory" default_wallet: "Specify the default wallet to use" delete_gpg_key: "Delete wallet sharing with an other GPG key" disable_alpha: "Don't use letters to create a password" @@ -73,7 +72,6 @@ en: new_group: "Define a group for the item" numeric: "Use number to create a password" otp_code: "Set an otp key" - path: "Move the wallet in new specify directory" pattern: "Given search pattern" pinmode: "Enable pinentry mode (available with gpg >= 2.1)" random_password: "Generate a random password" @@ -134,8 +132,6 @@ en: not_valid: "No data to import!" set_config: valid: "The config file has been edited!" - set_wallet_path: - valid: "The wallet has been moved!" setup_config: title: "Setup a new config file" lang: "Choose your language (en, fr, ...) [default=%{lang}]: " diff --git a/i18n/fr.yml b/i18n/fr.yml index 04583ad..4c474a5 100644 --- a/i18n/fr.yml +++ b/i18n/fr.yml @@ -46,7 +46,6 @@ fr: config: "Spécifie le fichier de configuration à utiliser" comment: "Spécifie un commentaire" clipboard: "Désactive la fonction presse papier" - default_path: "Déplace le portefeuille dans le dossier par défaut" default_wallet: "Spécifie le porte-feuille à utiliser par défaut" delete_gpg_key: "Supprime le partage le portefeuille avec une autre clé GPG" disable_alpha: "Désactive l'utilisation des lettres dans la génération d'un mot de passe" @@ -73,7 +72,6 @@ fr: new_group: "Spécifie le groupe de l'item" numeric: "Utilise des chiffre dans la génération d'un mot de passe" otp_code: "Spécifie un code OTP" - path: "Déplace le portefeuille dans un nouveau dossier" pattern: "Motif de donnée à chercher" pinmode: "Active le mode pinentry (valable avec gpg >= 2.1)" random_password: "Génére un mot de passe aléatoire" @@ -134,8 +132,6 @@ fr: not_valid: "Aucune donnée à importer!" set_config: valid: "Le fichier de configuration a bien été modifié!" - set_wallet_path: - valid: "Le portefeuille a bien été déplacé!" setup_config: title: "Création d'un nouveau fichier de configuration" lang: "Choisissez votre langue (en, fr, ...) [défaut=%{lang}]: " diff --git a/lib/mpw/cli.rb b/lib/mpw/cli.rb index 3eef7df..f3397b8 100644 --- a/lib/mpw/cli.rb +++ b/lib/mpw/cli.rb @@ -46,17 +46,6 @@ module MPW exit 2 end - # Change the wallet path - # @param path [String] new path - def set_wallet_path(path) - @config.set_wallet_path(path, @wallet) - - puts I18n.t('form.set_wallet_path.valid').to_s.green - rescue => e - puts "#{I18n.t('display.error')} #19: #{e}".red - exit 2 - end - # Create a new config file # @param options [Hash] def setup(options) @@ -112,8 +101,7 @@ module MPW 'gpg_exe' => @config.gpg_exe } - @config.wallet_paths.each { |k, v| config["path_wallet_#{k}"] = "#{v}/#{k}.mpw" } - @config.password.each { |k, v| config["password_#{k}"] = v } + @config.password.each { |k, v| config["password_#{k}"] = v } table_list('config', config) end @@ -376,7 +364,7 @@ module MPW # List all wallets def list_wallet - wallets = @config.wallet_paths.keys + wallets = [] Dir.glob("#{@config.wallet_dir}/*").each do |path| next unless File.directory?(path) @@ -407,12 +395,7 @@ module MPW wallet end - @wallet_path = - if @config.wallet_paths.key?(@wallet) - "#{@config.wallet_paths[@wallet]}/#{@wallet}" - else - "#{@config.wallet_dir}/#{@wallet}" - end + @wallet_path = "#{@config.wallet_dir}/#{@wallet}" end # Add a new public key diff --git a/lib/mpw/config.rb b/lib/mpw/config.rb index f3974b5..1c52a23 100644 --- a/lib/mpw/config.rb +++ b/lib/mpw/config.rb @@ -32,7 +32,6 @@ module MPW attr_accessor :config_dir attr_accessor :default_wallet attr_accessor :wallet_dir - attr_accessor :wallet_paths attr_accessor :gpg_exe attr_accessor :password attr_accessor :pinmode @@ -157,34 +156,5 @@ module MPW false end - - # Change the path of one wallet - # @param path [String]new directory path - # @param wallet [String] wallet name - def set_wallet_path(path, wallet) - path = @wallet_dir if path == 'default' - path = File.absolute_path(path) - - return if path == @wallet_dir && File.exist?("#{@wallet_dir}/#{wallet}.mpw") - return if path == @wallet_paths[wallet] - - old_wallet_file = - if @wallet_paths.key?(wallet) - "#{@wallet_paths[wallet]}/#{wallet}.mpw" - else - "#{@wallet_dir}/#{wallet}.mpw" - end - - FileUtils.mkdir_p(path) unless Dir.exist?(path) - FileUtils.mv(old_wallet_file, "#{path}/#{wallet}.mpw") if File.exist?(old_wallet_file) - - if path == @wallet_dir - @wallet_paths.delete(wallet) - else - @wallet_paths[wallet] = path - end - - setup - end end end diff --git a/test/test_cli.rb b/test/test_cli.rb index 8bae4cc..69e3e85 100644 --- a/test/test_cli.rb +++ b/test/test_cli.rb @@ -160,22 +160,6 @@ class TestConfig < Test::Unit::TestCase output = %x(mpw wallet) assert_match('| default', output) - - output = %x(mpw wallet --path '.') - assert_match(I18n.t('form.set_wallet_path.valid'), output) - - output = %x(mpw config) - assert_match(%r{path_wallet_default.+\| #{Dir.pwd}/default.mpw}, output) - assert(File.exist?("#{Dir.pwd}/default.mpw")) - - output = %x(mpw wallet) - assert_match('default', output) - - output = %x(mpw wallet --default-path) - assert_match(I18n.t('form.set_wallet_path.valid'), output) - - output = %x(mpw config) - assert_no_match(/path_wallet_default/, output) end def test_08_setup_config diff --git a/test/test_config.rb b/test/test_config.rb index 2b88b54..d7d48fb 100644 --- a/test/test_config.rb +++ b/test/test_config.rb @@ -61,19 +61,4 @@ class TestConfig < Test::Unit::TestCase assert(!@config.password[:numeric]) assert(@config.password[:special]) end - - def test_02_wallet_paths - new_path = '/tmp/mpw-test' - - @config = MPW::Config.new - @config.load_config - - assert(!@config.wallet_paths['default']) - - @config.set_wallet_path(new_path, 'default') - assert_equal(@config.wallet_paths['default'], new_path) - - @config.set_wallet_path('default', 'default') - assert(!@config.wallet_paths['default']) - end end