Sha256: 731ad1c6d0d942bc016bbc75aa04490fdf5b6d0b9fc46aaa3a415cb9d07b006b

Contents?: true

Size: 994 Bytes

Versions: 1

Compression:

Stored size: 994 Bytes

Contents

# frozen_string_literal: true

module CobraCommander
  # @private
  class CLI
    private_class_method def self.filter_options(dependents:, dependencies:)
      method_option :dependencies, type: :boolean, aliases: "-d", desc: dependencies
      method_option :dependents, type: :boolean, aliases: "-D", desc: dependents
      method_option :self, type: :boolean, default: true, desc: "Include the own component"
    end

  private

    def find_component(name)
      return umbrella.root unless name

      umbrella.find(name) || error("Component #{name} not found, try one of `cobra ls`") || exit(1)
    end

    def components_filtered(component_name)
      return umbrella.components unless component_name

      component = find_component(component_name)
      components = options.self ? [component] : []
      components.concat component.deep_dependencies if options.dependencies
      components.concat component.deep_dependents if options.dependents
      components
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cobra_commander-0.12.0 lib/cobra_commander/cli/filters.rb