Sha256: 38c23e0a885da60d19573aafc31bf5a1eab915201a7cd398dc15fb0866cd6adf

Contents?: true

Size: 777 Bytes

Versions: 5

Compression:

Stored size: 777 Bytes

Contents

# frozen_string_literal: true

module Rubysmith
  module CLI
    module Actions
      # Handles the config action.
      class Config
        def initialize client: CLI::Configuration::Loader::CLIENT, container: Container
          @client = client
          @container = container
        end

        def call selection
          case selection
            when :edit then edit
            when :view then view
            else fail StandardError, "Invalid configuration selection: #{selection}."
          end
        end

        private

        attr_reader :client, :container

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

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

        def kernel = container[__method__]
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rubysmith-0.16.1 lib/rubysmith/cli/actions/config.rb
rubysmith-0.16.0 lib/rubysmith/cli/actions/config.rb
rubysmith-0.15.0 lib/rubysmith/cli/actions/config.rb
rubysmith-0.14.0 lib/rubysmith/cli/actions/config.rb
rubysmith-0.13.0 lib/rubysmith/cli/actions/config.rb