ASSETS.cli.config do |cnf| cnf.people_filters do |filters| filters.add("-only-users") do |people, session, options| options.deep_merge!(people: {filter: {account: true}}) people.users end filters.add("-no-account") do |people, session, options| options.deep_merge!(people: {filter: {account: false}}) people.account_present(false) end filters.add("-with-details") do |people, session, options| options.deep_merge!(people: {filter: {details: true}}) people.details_present end filters.add("-no-id") do |people, session, options| options.deep_merge!(people: {filter: {external_id: nil}}) people.external_id_present(false) end filters.add("-supervisors") do |people, session, options| options.deep_merge!(people: {filter: {subordinates: true}}) people.newFrom people.to_a.select {|person| person.subordinates > 0} end filters.add("-supervisor-id") do |people, session, options| id = SCR.get_arg("-supervisor-id", with_param: true) options.deep_merge!(people: {filter: {supervisor_id: id}}) unless sup = people.person(id: id, external_id: id, email: id, strict: true) status = session.batch.search([{"id" => id}]) sup = status.people.first end raise "Supervisor with id '#{id}' does not exist" unless sup people.supervisor_id(sup.id) end filters.add("-no-default-tag") do |people, session, options| options.deep_merge!(people: {filter: {account: {default_tag: nil}}}) filtered = people.select do |person| !person.account&.default_tag end people.newFrom filtered end filters.add("-schema-id") do |people, session, options| sch_name = SCR.get_arg("-schema-id", with_param: true) sch_id = session.schemas.to_id(sch_name) unless sch_id puts "You need to specify the schema id" exit end options.deep_merge!(people: {filter: {details: {schema_id: sch_id}}}) session.logger.info("Filtering for schema #{sch_name}") session.schema = sch_id filtered = people.select do |person| person.details && (person.details.schema_id == sch_id) end people.newFrom filtered end end end