lib/eco/cli/config/default/usecases.rb in eco-helpers-2.0.60 vs lib/eco/cli/config/default/usecases.rb in eco-helpers-2.0.61
- old
+ new
@@ -145,11 +145,11 @@
desc = "Input file dump into a CSV as is."
cases.add("-entries-to-csv", :import, desc, case_name: "entries-to-csv")
.add_option("-out") do |options|
file = SCR.get_file("-out")
- options.deep_merge(export: {file: file})
+ options.deep_merge!(export: {file: file})
end
desc = "Usage '-org-data-convert backup.json -restore-db-from'."
desc += " Transforms an input .json file to the values of the destination environment "
desc += " (names missmatch won't solve: i.e. usergroups)"
@@ -251,8 +251,56 @@
desc = "It does like -upsert-from and additionally removes account and supervisor of those in people that are not in the entries (leavers)"
cases.add("-hris-from", :sync, desc, case_name: "hris")
.add_option("-append-starters", as1) do |options|
options.deep_merge!(people: {append_created: true})
+ end
+
+ # Ooze cases
+ desc = "APIv2 Case: Exports the target register into a CSV"
+ cases.add("-export-register", :other, desc, case_name: "export-register") do |session, options, usecase|
+ file = SCR.get_file("-export-register", required: false, should_exist: false)
+ options.deep_merge!(export: {file: {name: file || "RegisterExport.csv", format: :csv}})
+
+ unless options.dig(:source, :register_id)
+ session.logger.error "You should specify the target register id"
+ exit(1)
+ end
+ end.add_option("-register-id", "Target register id") do |options|
+ reg_id = SCR.get_arg("-register-id", with_param: true)
+ options.deep_merge!(source: {register_id: reg_id})
+ end.add_option("-include-deindexed", "Tells if deindexed fields should be included") do |options|
+ options.deep_merge!(export: {options: {include: {deindexed: true}}})
+ end.add_option("-include-unnamed", "Tells if unnamed fields should be included") do |options|
+ options.deep_merge!(export: {options: {include: {unnamed: true}}})
+ end.add_option("-include-unhashed", "Tells if fields with no hash reference (very short label) should be included") do |options|
+ options.deep_merge!(export: {options: {include: {unhashed: true}}})
+ end.add_option("-delimiter", "Sets the delimiter to be used in fields multi value") do |options|
+ str = SCR.get_arg("-delimiter", with_param: true)
+ options.deep_merge!(export: {options: {delimiter: str}})
+ end.add_option("-created-from", "Filters the register to the entries created FROM the specified date") do |options|
+ str = SCR.get_arg("-created-from", with_param: true)
+ date = Time.parse(str)
+ options.deep_merge!(export: {options: {filters: {created_at: {from: date}}}})
+ end.add_option("-created-to", "Filters the register to the entries created up TO the specified date") do |options|
+ str = SCR.get_arg("-created-to", with_param: true)
+ date = Time.parse(str)
+ options.deep_merge!(export: {options: {filters: {created_at: {to: date}}}})
+ end.add_option("-updated-from", "Filters the register by entries updated FROM the specified date") do |options|
+ str = SCR.get_arg("-updated-from", with_param: true)
+ date = Time.parse(str)
+ options.deep_merge!(export: {options: {filters: {updated_at: {from: date}}}})
+ end.add_option("-updated-to", "Filters the register by entries updated up TO the specified date") do |options|
+ str = SCR.get_arg("-updated-to", with_param: true)
+ date = Time.parse(str)
+ options.deep_merge!(export: {options: {filters: {updated_at: {to: date}}}})
+ end.add_option("-all-tags", "Filters the register to entries with ALL specified tags (| separator)") do |options|
+ str = SCR.get_arg("-all-tags", with_param: true)
+ tags = str.split("|")
+ options.deep_merge!(export: {options: {filters: {tags: {all: tags}}}})
+ end.add_option("-any-tags", "Filters the register to entries with ANY specified tags (| separator)") do |options|
+ str = SCR.get_arg("-all-tags", with_param: true)
+ tags = str.split("|")
+ options.deep_merge!(export: {options: {filters: {tags: {any: tags}}}})
end
end
end