Sha256: d7d6c335e82e79bf37c3379381e82a4956be96c215099d5752ab311b4e50c45c
Contents?: true
Size: 1.79 KB
Versions: 24
Compression:
Stored size: 1.79 KB
Contents
module Eco class CLI class Config attr_reader :cli def initialize(cli:) @cli = cli end def options cli.options end def args cli.args end def options_set @opions_set ||= Eco::CLI::Config::OptionsSet.new(core_config: self) @opions_set.tap do |opts_set| yield(opts_set, options) if block_given? end end def input(default_option: nil) @input ||= Eco::CLI::Config::Input.new(core_config: self, default_option: default_option) if block_given? @input.define(&Proc.new) self else @input end end def people(io: nil) if block_given? @people_load = Proc.new self else raise "There is no definition on how to load people" unless instance_variable_defined?(:@people_load) && @people_load unless io && io.is_a?(Eco::API::UseCases::BaseIO) raise "You need to provide Eco::API::UseCases::BaseIO object. Given: #{io.class}" end io = io.new(type: :import) @people_load.call(*io.params) end end def people_filters @people_filters ||= Eco::CLI::Config::PeopleFilters.new(core_config: self) @people_filters.tap do |filters| yield(filters) if block_given? end end def usecases @usecases ||= Eco::CLI::Config::UseCases.new(core_config: self) @usecases.tap do |cases| yield(cases) if block_given? end end end end end require_relative 'config/options_set' require_relative 'config/input' require_relative 'config/people_filters' require_relative 'config/use_cases'
Version data entries
24 entries across 24 versions & 1 rubygems