Sha256: 027d0a0f763aef18c2fea9f724395d0553b2f0b7f61dad96a2ba427c652182c5

Contents?: true

Size: 736 Bytes

Versions: 3

Compression:

Stored size: 736 Bytes

Contents

# frozen_string_literal: true

module Pragmater
  module CLI
    module Actions
      # Handles the config action.
      class Config
        include Pragmater::Import[:kernel, :logger]

        def initialize(client: Configuration::Loader::CLIENT, **)
          super(**)
          @client = client
        end

        def call selection
          case selection
            when :edit then edit
            when :view then view
            else logger.error { "Invalid configuration selection: #{selection}." }
          end
        end

        private

        attr_reader :client

        def edit = kernel.system("$EDITOR #{client.current}")

        def view = kernel.system("cat #{client.current}")
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
pragmater-12.2.0 lib/pragmater/cli/actions/config.rb
pragmater-12.1.2 lib/pragmater/cli/actions/config.rb
pragmater-12.1.1 lib/pragmater/cli/actions/config.rb