class Eco::API::UseCases::Default::People::Treat::OrgDataConvertCase class Cli < Eco::API::UseCases::Cli str = "Usage '#{cli_name} backup.json -restore-db-from'." str << " Transforms an input .json file to the values of the destination environment " str << " (names missmatch won't solve: i.e. usergroups)" desc str callback do |input, session, options| unless input.is_a?(Eco::API::Organization::People) file = SCR.get_file(cli_name, required: true) input = Eco::API::Organization::People.new(JSON.parse(File.read(file))) session.log(:info) { "Source DB: loaded #{input.length} entries." } end unless options[:source_enviro] session.log(:error) { "You need to specify a -source-enviro for the conversion to work out" } exit(1) end end str = "The defined -source-enviro API configuration that the backup file was generated from" add_option("-source-enviro", str) do |options| options.merge!(source_enviro: SCR.get_arg("-source-enviro", with_param: true)) end str = "Prevents the script to crash when backup file has missing usergroups in the org" add_option("-ignore-missing-policy-groups", str) do |options| options.deep_merge!(ignore: {missing: {policy_groups: true}}) end end end