ASSETS.cli.config do |cnf| cnf.usecases do |cases| cases.add("-people-to-csv", :export) do |people, session, options| file = SCR.get_file("-people-to-csv", required: true, should_exist: false) options.deep_merge!(export: {file: {name: file, format: :csv}}) options.deep_merge!(export: {options: {nice_header: true}}) if SCR.get_arg("-nice-header") case_name = SCR.get_arg("-detailed")? "to-csv-detailed" : "to-csv" session.usecases.case(case_name) end cases.add("-reset-landing-page", :transform, case_name: "reset-landing-page") cases.add("-email-as-id", :transform, case_name: "email-as-id") cases.add("-new-id-from", :sync, case_name: "new-id") # won't succeed if some other user with that email in all eP cases.add("-new-email-from", :sync, case_name: "new-email") # forces the change of email no matter what, # unless some other user with that email in the same organization cases.add("-change-email-from", :sync, case_name: "change-email") cases.add("-set-supervisor-from", :sync, case_name: "set-supervisor") cases.add("-switch-supervisor", :transform, case_name: "switch-supervisor") do |people, session, options| unless old_id = SCR.get_arg("-old-super", with_param: true) msg = "You must specify an -old-super to target whose supervisor is changing" session.logger.error(msg) exit(1) end options.deep_merge!(super: {old: old_id}) unless new_id = SCR.get_arg("-new-super", with_param: true) msg = "You must specify the -new-super id. To reset to nil the supervisor, please, specify nil." session.logger.error(msg) exit(1) end new_id = new_id == "nil"? nil : new_id options.deep_merge!(super: {new: new_id}) end cases.add("-create-details-from", :sync, case_name: "create-details") cases.add("-update-details-from", :sync, case_name: "update-details") cases.add("-reinvite", :transform, case_name: "reinvite") cases.add("-reinvite-from", :sync, case_name: "reinvite") cases.add("-set-default-tag", :transform, case_name: "set-default-tag") cases.add("-recover-db-from", :sync, case_name: "recover-db") do |input, people, session, options| unless input && input.is_a?(Eco::API::Organization::People) file = SCR.get_file("-recover-db-from", required: true) input = Eco::API::Organization::People.new(JSON.parse(File.read(file))) session.logger.info("Source DB: loaded #{input.length} entries.") end options.deep_merge!(include: {delete: true}) if SCR.get_arg("-include-delete") options.deep_merge!(include: {create: true}) if SCR.get_arg("-include-create") end cases.add("-create-from", :sync, case_name: "create") cases.add("-update-from", :sync, case_name: "update") cases.add("-refresh", :transform, case_name: "refresh") cases.add("-refresh-presets", :transform, case_name: "refresh-presets") cases.add("-remove-account", :transform, case_name: "remove-account") cases.add("-remove-account-from", :sync, case_name: "remove-account") cases.add("-delete", :transform, case_name: "delete") cases.add("-delete-from", :sync, case_name: "delete") cases.add("-upsert-from", :sync, case_name: "upsert") cases.add("-hris-from", :sync, case_name: "hris") end end