Sha256: a3bd4e4d8af558df6fee6f88407c9040f833c0082dc6c60783e4d0156e7acddc

Contents?: true

Size: 851 Bytes

Versions: 7

Compression:

Stored size: 851 Bytes

Contents

# frozen_string_literal: true

module Pennyworth
  module CLI
    module Actions
      # Handles the configuration action.
      class Config
        def initialize configuration: Configuration::Loader::CLIENT, container: Container
          @configuration = configuration
          @container = container
        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, :container

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

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

        def kernel = container[__method__]

        def logger = container[__method__]
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
pennyworth-12.3.1 lib/pennyworth/cli/actions/config.rb
pennyworth-12.3.0 lib/pennyworth/cli/actions/config.rb
pennyworth-12.2.0 lib/pennyworth/cli/actions/config.rb
pennyworth-12.1.0 lib/pennyworth/cli/actions/config.rb
pennyworth-12.0.2 lib/pennyworth/cli/actions/config.rb
pennyworth-12.0.1 lib/pennyworth/cli/actions/config.rb
pennyworth-12.0.0 lib/pennyworth/cli/actions/config.rb