Sha256: d967c318367073147efef4882ad9351bb428e3a6c29a41c6dee452d8caef2c2b

Contents?: true

Size: 978 Bytes

Versions: 15

Compression:

Stored size: 978 Bytes

Contents

# frozen_string_literal: true

require "active_support/encrypted_file"

module Jets
  module Command
    module Helpers
      module Editor
        private
          def ensure_editor_available(command:)
            if ENV["EDITOR"].to_s.empty?
              say "No $EDITOR to open file in. Assign one like this:"
              say ""
              say %(EDITOR="mate --wait" #{command})
              say ""
              say "For editors that fork and exit immediately, it's important to pass a wait flag,"
              say "otherwise the credentials will be saved immediately with no chance to edit."

              false
            else
              true
            end
          end

          def catch_editing_exceptions
            yield
          rescue Interrupt
            say "Aborted changing file: nothing saved."
          rescue ActiveSupport::EncryptedFile::MissingKeyError => error
            say error.message
          end
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
jets-5.0.13 lib/jets/command/helpers/editor.rb
jets-5.0.12 lib/jets/command/helpers/editor.rb
jets-5.0.11 lib/jets/command/helpers/editor.rb
jets-5.0.10 lib/jets/command/helpers/editor.rb
jets-5.0.9 lib/jets/command/helpers/editor.rb
jets-5.0.8 lib/jets/command/helpers/editor.rb
jets-5.0.7 lib/jets/command/helpers/editor.rb
jets-5.0.6 lib/jets/command/helpers/editor.rb
jets-5.0.5 lib/jets/command/helpers/editor.rb
jets-5.0.4 lib/jets/command/helpers/editor.rb
jets-5.0.3 lib/jets/command/helpers/editor.rb
jets-5.0.2 lib/jets/command/helpers/editor.rb
jets-5.0.1 lib/jets/command/helpers/editor.rb
jets-5.0.0 lib/jets/command/helpers/editor.rb
jets-5.0.0.beta1 lib/jets/command/helpers/editor.rb