Sha256: f53dcd4e05e9321e2f608b8f9d8344a98016f4c84dd4f1b901a8ff58d78357a8

Contents?: true

Size: 775 Bytes

Versions: 4

Compression:

Stored size: 775 Bytes

Contents

# frozen_string_literal: true

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

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

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

        private

        attr_reader :configuration

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

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
pennyworth-14.3.0 lib/pennyworth/cli/actions/config.rb
pennyworth-14.2.1 lib/pennyworth/cli/actions/config.rb
pennyworth-14.2.0 lib/pennyworth/cli/actions/config.rb
pennyworth-14.1.2 lib/pennyworth/cli/actions/config.rb