Sha256: efb8eead80a9d9d452e4ffea2e3df777f054097fb6da08e95f17b3418599e6cb

Contents?: true

Size: 736 Bytes

Versions: 6

Compression:

Stored size: 736 Bytes

Contents

# frozen_string_literal: true

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

        def initialize(client: Configuration::Loader::CLIENT, **)
          super(**)
          @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

6 entries across 6 versions & 1 rubygems

Version Path
rubysmith-4.9.0 lib/rubysmith/cli/actions/config.rb
rubysmith-4.8.0 lib/rubysmith/cli/actions/config.rb
rubysmith-4.7.0 lib/rubysmith/cli/actions/config.rb
rubysmith-4.6.1 lib/rubysmith/cli/actions/config.rb
rubysmith-4.6.0 lib/rubysmith/cli/actions/config.rb
rubysmith-4.5.0 lib/rubysmith/cli/actions/config.rb