lib/eco/cli/config/default/workflow.rb in eco-helpers-1.1.8 vs lib/eco/cli/config/default/workflow.rb in eco-helpers-1.2.1
- old
+ new
@@ -2,28 +2,50 @@
ASSETS.config.workflow do |wf|
io = nil
# default rescue
wf.rescue do |exception, io|
- #io.session.logger.error(exception.patch_full_message)
+ io.session.logger.error(exception.patch_full_message)
wf.run(:close, io: io)
io
end
wf.on(:options) do |wf_options, io|
io = io.new(options: config.options_set.process(io: io))
end
wf.for(:load) do |wf_load|
+ active_cases = nil
+
wf_load.on(:input) do |wf_input, io|
- io = io.new(input: config.input.get(io: io))
+ active_cases = config.usecases.active(io: io)
+
+ cases_with_input = active_cases.select do |usecase, data|
+ io.class.input_required?(usecase.type)
+ end
+
+ next io unless (!io.input || io.input.empty?) && !cases_with_input.empty?
+
+ if io.options.dig(:input, :entries_from)
+ io = io.new(input: config.input.get(io: io))
+ else
+ opt_case = cases_with_input.values.first[:option]
+ io = io.new(input: config.input.get(io: io, option: opt_case))
+ end
+ io
end
wf_load.on(:people) do |wf_people, io|
+ cases_with_people = active_cases.select do |usecase, data|
+ io.class.people_required?(usecase.type)
+ end
+ get_people = io.options.dig(:people, :get, :from) == :remote
+ next io unless !cases_with_people.empty? || get_people
io = io.new(people: config.people(io: io))
end
wf_load.on(:filter) do |wf_filter, io|
+ next io unless io.people && !io.people.empty?
io = io.new(people: config.people_filters.process(io: io))
end
end
wf.before(:usecases) do |wf_cases, io|