ASSETS.cli.config do |cnf| cnf.options_set do |options_set, options| options_set.add("--help", "Offers a HELP") do |options, sesssion| conf = ASSETS.cli.config active = Proc.new do |opt| if there = SCR.get_arg(opt) refine = SCR.get_arg(opt, with_param: true) end refine || there end if hpf = active.call("-filters") puts conf.people_filters.help(refine: hpf) end if hif = active.call("-input-filters") puts conf.input_filters.help(refine: hif) end if ho = active.call("-options") puts conf.options_set.help(refine: ho) end if huc = active.call("-usecases") puts conf.usecases.help(refine: huc) end puts [ "Please specify one of the below:", " -filters to display available filters on people", " -input-filters to display available filters on input data", " -options to dislpay available options", " -usecases to display available usecases", "TIPS:", " * You may specify the usecase to know its specific options by: -usecase_name --help -options", " * You may specify a refinement to show specific information only: --help -usecases tags" ].join("\n") unless hpf || hif || ho || huc exit end desc = "Redirect Standard Ouput to file" options_set.add("-stdout", desc) do |options, session| file = SCR.get_arg("-stdout", with_param: true) || "output.txt" STDOUT.reopen(file, "w+") end desc = "Skips the check of the headers" options_set.add("-skip-header-check", desc) do |options, session| options.deep_merge!(input: {skip_header_check: true}) end desc = "Fix the current session to work with this schema" options_set.add("-schema-id", desc) do |options, session| sch_name = SCR.get_arg("-schema-id", with_param: true) sch_id = session.schemas.to_id(sch_name) unless sch_id msg = "You need to specify a correct schema id or name. '#{sch_name}' does not exist" session.logger.error(msg) exit(1) end options.deep_merge!(people: {filter: {details: {schema_id: sch_id}}}) session.logger.info("Setting schema #{session.schemas.to_name(sch_id)}") session.schema = sch_id end desc = "Used to be used to specify the input file or folder when using -get-partial." desc += "It can also be useful to obtain `-get-partial` of people base on `:export` use cases (i.e. -people-to-csv)" options_set.add("-entries-from", desc) do |options, session| options.deep_merge!(input: {entries_from: true}) end desc = "Used to only get the people from the input file. It will also include their current and new supervisors." options_set.add("-get-partial", desc) do |options, session| options.deep_merge!(people: { get: {from: :remote, type: :partial} }) end desc = "Do not load any people for this run." options_set.add("-no-people", desc) do |options, session| options.deep_merge!(people: {get: false}) end desc = "Locally cache all the people manager by retrieving from the server" options_set.add("-get-people", desc) do |options, session| options.deep_merge!(people: { get: {from: :remote, type: :full} }) end desc = "Saves the requests's body even though running in dry-run (-simulate)" options_set.add("-save-requests", desc) do |options, session| options.deep_merge!(requests: {backup: true}) end desc = "Used to specify the cache file of people to be used. " desc += "It is useful to use as people reference those stored in cached file diffrent to the last one." options_set.add("-people-from-backup", desc) do |options, session| file = SCR.get_file("-people-from-backup", required: true, should_exist: true) options.deep_merge!(people: { get: {from: :local, type: :file, file: file} }) end desc = "Used to export to a csv the final people (after processing). " desc += "It is useful analyse the data after a -dry-run (-simulate)." options_set.add("-processed-people-to-csv", desc) do |options, session| file = SCR.get_file("-processed-people-to-csv", required: true, should_exist: false) options.deep_merge!(report: {people: {csv: file}}) end desc = "Runs in dry-run (no requests sent to server)" options_set.add(["-dry-run", "-simulate"], desc) do |options, session| options[:dry_run] = true options[:simulate] = true session.config.dry_run! end desc = "Runs runs post_launch cases even if in dry-run" options_set.add("-run-postlaunch", desc) do |options, session| options.deep_merge!(post_launch: {run: true}) end desc = "(careful with this option) This will include everybody as part of the update (including those that are api excluded). " desc += "Only launch with this option when only api excluded people are included in your update." options_set.add("-include-excluded", desc) do |options| options.deep_merge!(include: {excluded: true}) end desc = "Includes in API updates ONLY people that evaluate true as people excluded from periodic upates." options_set.add("-include-only-excluded", desc) do |options| options.deep_merge!(include: {excluded: {only: true}}) end desc = "Ignores threshold limitations on requests for this session (skip batch belt)" options_set.add("-skip-batch-policy", desc) do |options| options.deep_merge!(skip: {batch_policy: true}) end desc = "Will not run the api policies defined for the enviro" options_set.add("-skip-api-policies", desc) do |options| options.deep_merge!(skip: {api_policies: true}) end options_set.add("-feed-only-stats", "Shows only stats when giving feedback") do |options| options.deep_merge!(feedback: {only_stats: true}) end desc = "Deprecated: used to be used to avoid reloading people after launch" options[:end_get] = true options_set.add("-no-get", desc) do |options| options[:end_get] = false end desc = "Force search mode to 'strict' when pairing input entries with existing people." desc += " Besides id and external_id it will not try to find by email unless external_id is not specified" options_set.add("-search-strict", desc) do |options| options.deep_merge!(search: {strict: true}) end desc = "Search mode that will try to find people using email when id and external_id have failed" desc += " This option could identify existing people by their email addresses" desc += " (it should not be used in orgs where multiple people usually have the same email address)" options_set.add("-search-soft", desc) do |options| options.deep_merge!(search: {soft: true, strict: false}) end desc = "Silence notifications on account creation or invites" options_set.add(["-no-invites", "-exclude-invites"], desc) do |options| options.merge!(send_invites: false) end desc = "People with account will be reinvited if they haven't accepted the invitation" options_set.add("-send-invites", desc) do |options| options.merge!(send_invites: true) end options_set.add("-exclude-core", "Core input data is not used on the update") do |options| options.deep_merge!(exclude: {core: true}) end options_set.add("-exclude-filter-tags", "filter_tags is not set with the input data") do |options| options.deep_merge!(exclude: {filter_tags: true}) end options_set.add("-exclude-external-id", "external_id is not set with the input data") do |options| options.deep_merge!(exclude: {external_id: true}) end options_set.add("-exclude-supervisor", "supervisor_id is not set with the input data") do |options| options.deep_merge!(exclude: {supervisor: true}) end options_set.add("-exclude-email", "email is not set with the input data") do |options| options.deep_merge!(exclude: {email: true}) end options_set.add("-exclude-name", "name is not set with the input data") do |options| options.deep_merge!(exclude: {name: true}) end options_set.add("-exclude-details", "Details are not set with the input data") do |options| options.deep_merge!(exclude: {details: true}) end options_set.add("-exclude-account", "Account is not set with the input data") do |options| options.deep_merge!(exclude: {account: true}) end options_set.add("-exclude-policy-groups", "policy_group_ids is not set with the input data") do |options| options.deep_merge!(exclude: {policy_groups: true}) end options_set.add("-default-tag", "default_tag is not set with the input data") do |options| options.deep_merge!(exclude: {default_tag: true}) end options_set.add("-exclude-abilities", "permissions_custom is not set with the input data") do |options| options.deep_merge!(exclude: {abilities: true}) end options_set.add("-exclude-login-providers", "login_provider_ids is not set with the input data") do |options| options.deep_merge!(exclude: {login_providers: true}) end end end