Sha256: 1da52bebec48f6f149c586f954a211ddfc98e84247c8432cd04ff455d2a785f4

Contents?: true

Size: 751 Bytes

Versions: 9

Compression:

Stored size: 751 Bytes

Contents

# frozen_string_literal: true

module Tocer
  module CLI
    module Actions
      # Handles the config action.
      class Config
        include Tocer::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
tocer-15.1.0 lib/tocer/cli/actions/config.rb
tocer-15.0.0 lib/tocer/cli/actions/config.rb
tocer-14.5.0 lib/tocer/cli/actions/config.rb
tocer-14.4.0 lib/tocer/cli/actions/config.rb
tocer-14.3.0 lib/tocer/cli/actions/config.rb
tocer-14.2.0 lib/tocer/cli/actions/config.rb
tocer-14.1.0 lib/tocer/cli/actions/config.rb
tocer-14.0.1 lib/tocer/cli/actions/config.rb
tocer-14.0.0 lib/tocer/cli/actions/config.rb