Sha256: afb33439af0660035987bb03dc7fbbd8d44120c0050fa8ab19c3052245f259f4

Contents?: true

Size: 759 Bytes

Versions: 9

Compression:

Stored size: 759 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, **dependencies
          super(**dependencies)
          @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

9 entries across 9 versions & 1 rubygems

Version Path
pragmater-12.1.0 lib/pragmater/cli/actions/config.rb
pragmater-12.0.0 lib/pragmater/cli/actions/config.rb
pragmater-11.5.0 lib/pragmater/cli/actions/config.rb
pragmater-11.4.0 lib/pragmater/cli/actions/config.rb
pragmater-11.3.0 lib/pragmater/cli/actions/config.rb
pragmater-11.2.0 lib/pragmater/cli/actions/config.rb
pragmater-11.1.0 lib/pragmater/cli/actions/config.rb
pragmater-11.0.1 lib/pragmater/cli/actions/config.rb
pragmater-11.0.0 lib/pragmater/cli/actions/config.rb