ASSETS.cli.config do |config| ASSETS.config.workflow do |wf| io = nil # default rescue wf.rescue do |exception, io| #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| wf_load.on(:input) do |wf_input, io| io = io.new(input: config.input.get(io: io)) end wf_load.on(:people) do |wf_people, io| io = io.new(people: config.people(io: io)) end wf_load.on(:filter) do |wf_filter, io| io = io.new(people: config.people_filters.process(io: io)) 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.do.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(: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.do.file_people io = io.new(people: people) end io end end end