ASSETS.cli.config do |config| ASSETS.config.workflow do |wf| io = nil rescued = false # default rescue wf.rescue do |exception, io| next io if rescued rescued = true io.session.logger.debug(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| wf_load.for(:input) do |wf_input| wf_input.on(:get) do |wf_input_get, io| cases_with_input = config.usecases.active(io: io).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_input.on(:filter) do |wf_input_filter, io| next io unless io.input && !io.input.empty? io = io.new(input: config.input_filters.process(io: io)) end end wf_load.for(:people) do |wf_people| wf_people.on(:get) do |wf_people_get, io| cases_with_people = config.usecases.active(io: io).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_people.on(:filter) do |wf_people_filter, io| next io unless io.people && !io.people.empty? io = io.new(people: config.people_filters.process(io: io)) end end end wf.before(:usecases) do |wf_cases, io| # save partial entries -> should be native to session.workflow partial_update = io.options.dig(:people, :get, :type) == :partial if !io.options[:dry_run] && partial_update partial_file = io.session.config.people.partial_cache io.session.file_manager.save_json(io.people, partial_file, :timestamp) end io end wf.on(:usecases) do |wf_cases, io| unless config.usecases.process(io: io) msg = "No update operation specified... quitting" io.session.logger.warn(msg) exit(1) end io end wf.before(:launch_jobs) do |wf_jobs, io| SCR.stop_on_unknown! io end wf.on(:launch_jobs) do |wf_jobs, io| io.session.jobs_launch(simulate: io.options[:dry_run]) io end wf.before(:post_launch) do |wf_post, io| if io.session.post_launch.empty? wf_post.skip! else partial_update = io.options.dig(:people, :get, :type) == :partial if !io.options[:dry_run] && partial_update # get target people afresh people = io.session.micro.people_refresh(people: io.people, include_created: true) io = io.new(people: people) else wf_post.skip! msg = "Although there are post_launch cases, they will NOT be RUN" if io.options[:dry_run] msg+= ", because we are in dry-run (simulate)." elsif !partial_update msg+= ", because it is not a partial update (-get-partial)" end io.session.logger.info(msg) end end io end wf.for(:post_launch) do |wf_post| wf_post.on(:usecases) do |wf_postcases, io| io.session.post_launch.each do |use| io = use.launch(io: io).base end io end wf_post.on(:launch_jobs) do |wf_postlaunch, io| io.session.jobs_launch(simulate: io.options[:dry_run]) io end end wf.on(:report) do |wf_report, io| #config.reports.active(io: io) #io.session.reports io end wf.on(:end) do |wf_end, io| partial_update = io.options.dig(:people, :get, :type) == :partial unless !io.options[:end_get] || io.options[:dry_run] || partial_update people = io.session.micro.people_cache io = io.new(people: people) end io end end end