Sha256: 6025bbdaa8fba20d11dd7cdba1e4be0249767e384fcc712c09b1fe8e65ab2dec

Contents?: true

Size: 852 Bytes

Versions: 9

Compression:

Stored size: 852 Bytes

Contents

# frozen_string_literal: true

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

9 entries across 9 versions & 1 rubygems

Version Path
pennyworth-11.2.2 lib/pennyworth/cli/actions/config.rb
pennyworth-11.2.1 lib/pennyworth/cli/actions/config.rb
pennyworth-11.2.0 lib/pennyworth/cli/actions/config.rb
pennyworth-11.1.3 lib/pennyworth/cli/actions/config.rb
pennyworth-11.1.2 lib/pennyworth/cli/actions/config.rb
pennyworth-11.1.1 lib/pennyworth/cli/actions/config.rb
pennyworth-11.1.0 lib/pennyworth/cli/actions/config.rb
pennyworth-11.0.1 lib/pennyworth/cli/actions/config.rb
pennyworth-11.0.0 lib/pennyworth/cli/actions/config.rb