Sha256: 9cab6fbd9c61b3a983ff7e52298232b24d4f7d8b24a11d34a1781c9a69c064bf

Contents?: true

Size: 1.38 KB

Versions: 37

Compression:

Stored size: 1.38 KB

Contents

module Eco
  class CLI
    class Config
      class Filters
        include Eco::CLI::Config::Help
        attr_reader :core_config

        def initialize(core_config:)
          @core_config = core_config
          @filters     = {}
          @description = {}
        end

        # @return [String] summary of the filters.
        def help(msg = "The following are the available filters:")
          [msg].yield_self do |lines|
            max_len = keys_max_len(@filters.keys)
            @filters.keys.sort.each do |key|
              lines << help_line(key, @description[key], max_len)
            end
            lines
          end.join("\n")
        end

        # @param option [String] the command line option that activates this filter.
        # @param desc [String] description of the filter.
        def add(option, desc = nil)
          raise "Missing block to define the filters builder" unless block_given?
          callback = Proc.new
          [option].flatten.compact.each do |opt|
            @filters[opt]     = callback
            @description[opt] = desc
          end
          self
        end

        def process(io:)
          raise "You need to override this method in child classes"
        end

        private


      end
    end
  end
end

require_relative 'filters/people_filters'
require_relative 'filters/input_filters'

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
eco-helpers-2.0.25 lib/eco/cli/config/filters.rb
eco-helpers-2.0.24 lib/eco/cli/config/filters.rb
eco-helpers-2.0.23 lib/eco/cli/config/filters.rb
eco-helpers-2.0.22 lib/eco/cli/config/filters.rb
eco-helpers-2.0.21 lib/eco/cli/config/filters.rb
eco-helpers-2.0.19 lib/eco/cli/config/filters.rb
eco-helpers-2.0.18 lib/eco/cli/config/filters.rb
eco-helpers-2.0.17 lib/eco/cli/config/filters.rb
eco-helpers-2.0.16 lib/eco/cli/config/filters.rb
eco-helpers-2.0.15 lib/eco/cli/config/filters.rb
eco-helpers-2.0.14 lib/eco/cli/config/filters.rb
eco-helpers-2.0.13 lib/eco/cli/config/filters.rb
eco-helpers-2.0.12 lib/eco/cli/config/filters.rb
eco-helpers-2.0.11 lib/eco/cli/config/filters.rb
eco-helpers-2.0.10 lib/eco/cli/config/filters.rb
eco-helpers-2.0.9 lib/eco/cli/config/filters.rb
eco-helpers-2.0.8 lib/eco/cli/config/filters.rb
eco-helpers-2.0.7 lib/eco/cli/config/filters.rb
eco-helpers-2.0.6 lib/eco/cli/config/filters.rb
eco-helpers-2.0.5 lib/eco/cli/config/filters.rb