Sha256: af634534de8974e71b817c49f6c7419f2b5bd8b94d95e96875b0fe26ffd5e97a

Contents?: true

Size: 1.31 KB

Versions: 7

Compression:

Stored size: 1.31 KB

Contents

# frozen_string_literal: true

require 'avm/self'
require 'avm/tools/core_ext'
require 'eac_config/node'
require 'eac_ruby_utils/recursive_builder'

module Avm
  module Tools
    class Runner
      class Config
        class LoadPath
          runner_with :help do
            desc 'Manipulate include path.'
            arg_opt '-p', '--push', 'Add a path.'
          end

          def run
            config_nodes.each { |config_node| run_show(config_node) }
            run_add
          end

          private

          # @return [[EacCli::Config]]
          def root_config_node
            ::EacConfig::Node.context.current
          end

          def config_nodes
            ::EacRubyUtils::RecursiveBuilder.new(root_config_node, &:self_loaded_nodes).result
          end

          def run_add
            parsed.push.if_present do |v|
              infov 'Path to add', v
              config_node.load_path.push(v)
              success 'Path included'
            end
          end

          def run_show(config_node)
            infov 'Configuration path', config_node.url
            infov 'Paths included', config_node.self_loaded_nodes.count
            config_node.self_loaded_nodes.each do |loaded_node|
              infov '  * ', loaded_node.url
            end
          end
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
avm-tools-0.113.0 lib/avm/tools/runner/config/load_path.rb
avm-tools-0.112.0 lib/avm/tools/runner/config/load_path.rb
avm-tools-0.111.0 lib/avm/tools/runner/config/load_path.rb
avm-tools-0.110.0 lib/avm/tools/runner/config/load_path.rb
avm-tools-0.109.1 lib/avm/tools/runner/config/load_path.rb
avm-tools-0.109.0 lib/avm/tools/runner/config/load_path.rb
avm-tools-0.108.0 lib/avm/tools/runner/config/load_path.rb