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'