Class: Eco::CLI::Config
- Inherits:
-
Object
show all
- Defined in:
- lib/eco/cli/config.rb,
lib/eco/cli/config/help.rb,
lib/eco/cli/config/input.rb,
lib/eco/cli/config/filters.rb,
lib/eco/cli/config/use_cases.rb,
lib/eco/cli/config/options_set.rb,
lib/eco/cli/config/filters/input_filters.rb,
lib/eco/cli/config/filters/people_filters.rb
Defined Under Namespace
Modules: Help
Classes: Filters, Input, OptionsSet, UseCases
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(cli:) ⇒ Config
Returns a new instance of Config.
6
7
8
|
# File 'lib/eco/cli/config.rb', line 6
def initialize(cli:)
@cli = cli
end
|
Instance Attribute Details
Returns the value of attribute cli.
4
5
6
|
# File 'lib/eco/cli/config.rb', line 4
def cli
@cli
end
|
Instance Method Details
14
15
16
|
# File 'lib/eco/cli/config.rb', line 14
def args
cli.args
end
|
#available_option_args ⇒ Object
All the available known option args that can be used in the CLI
19
20
21
22
23
24
25
26
|
# File 'lib/eco/cli/config.rb', line 19
def available_option_args
[
usecases.available(keys: true),
options_set.available(keys: true),
people_filters.available(keys: true),
input_filters.available(keys: true)
].flatten.uniq
end
|
35
36
37
38
39
40
41
|
# File 'lib/eco/cli/config.rb', line 35
def input(default_option: nil, &block)
@input ||= Eco::CLI::Config::Input.new(core_config: self, default_option: default_option)
return @input unless block_given?
@input.define(&block)
self
end
|
66
67
68
69
70
71
|
# File 'lib/eco/cli/config.rb', line 66
def input_filters
@input_filters ||= Eco::CLI::Config::Filters::InputFilters.new(core_config: self)
@input_filters.tap do |filters|
yield(filters) if block_given?
end
end
|
10
11
12
|
# File 'lib/eco/cli/config.rb', line 10
def options
cli.options
end
|
#options_set ⇒ Object
28
29
30
31
32
33
|
# File 'lib/eco/cli/config.rb', line 28
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
|
#people(io: nil, &block) ⇒ Object
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
# File 'lib/eco/cli/config.rb', line 43
def people(io: nil, &block)
if block_given?
@people_load = block
self
else
msg = "There is no definition on how to load people"
raise msg unless instance_variable_defined?(:@people_load) && @people_load
msg = "You need to provide Eco::API::UseCases::BaseIO object. Given: #{io.class}"
raise msg unless io.is_a?(Eco::API::UseCases::BaseIO)
io = io.new(type: :import, input: io.input || [])
@people_load.call(*io.params)
end
end
|
#people_filters ⇒ Object
59
60
61
62
63
64
|
# File 'lib/eco/cli/config.rb', line 59
def people_filters
@people_filters ||= Eco::CLI::Config::Filters::PeopleFilters.new(core_config: self)
@people_filters.tap do |filters|
yield(filters) if block_given?
end
end
|
73
74
75
76
77
78
|
# File 'lib/eco/cli/config.rb', line 73
def usecases
@usecases ||= Eco::CLI::Config::UseCases.new(core_config: self)
@usecases.tap do |cases|
yield(cases) if block_given?
end
end
|