diff --git a/lib/mpw/cli.rb b/lib/mpw/cli.rb index 2f9ad31..c3a953f 100644 --- a/lib/mpw/cli.rb +++ b/lib/mpw/cli.rb @@ -79,9 +79,6 @@ class Cli # Setup a new GPG key # @args: gpg_key -> the key name def setup_gpg_key(gpg_key) - puts I18n.t('form.setup_gpg_key.title') - puts '--------------------' - ask = ask(I18n.t('form.setup_gpg_key.ask')).to_s password = ask(I18n.t('form.setup_gpg_key.password')) {|q| q.echo = false} confirm = ask(I18n.t('form.setup_gpg_key.confirm_password')) {|q| q.echo = false} @@ -294,6 +291,8 @@ class Cli # Display the wallet # @args: wallet -> the wallet name def get_wallet(wallet=nil) + @config.is_valid? + if wallet.to_s.empty? wallets = Dir.glob("#{@config.wallet_dir}/*.mpw") @@ -390,7 +389,7 @@ class Cli @mpw.sync(true) if @sync puts "#{I18n.t('form.add_item.valid')}".green - #rescue Exception => e + rescue Exception => e puts "#{I18n.t('display.error')} #13: #{e}".red end diff --git a/lib/mpw/mpw.rb b/lib/mpw/mpw.rb index f4e8ce3..11c1293 100644 --- a/lib/mpw/mpw.rb +++ b/lib/mpw/mpw.rb @@ -500,12 +500,12 @@ class MPW recipients = [] crypto = GPGME::Crypto.new(armor: true, always_trust: true) + recipients.push(@key) @keys.each_key do |key| + next if key == @key recipients.push(key) end - recipients.push(@key) if not recipients.index(@key).nil? - return crypto.encrypt(data, recipients: recipients).read rescue Exception => e raise "#{I18n.t('error.gpg_file.encrypt')}\n#{e}"