lib/eco/cli/config/default/usecases.rb in eco-helpers-1.5.5 vs lib/eco/cli/config/default/usecases.rb in eco-helpers-1.5.6

- old
+ new

@@ -53,9 +53,30 @@ end new_id = new_id == "nil"? nil : new_id options.deep_merge!(super: {new: new_id}) 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)" + cases.add("-org-data-convert", :import, desc, case_name: "org-data-convert") do |input, session, options| + unless input && input.is_a?(Eco::API::Organization::People) + file = SCR.get_file("-org-data-convert", required: true) + input = Eco::API::Organization::People.new(JSON.parse(File.read(file))) + session.logger.info("Source DB: loaded #{input.length} entries.") + end + + if source_enviro = SCR.get_arg("-source-enviro", with_param: true) + options.merge!(source_enviro: source_enviro) + else + session.logger.error("You need to specify a -source-enviro for the conversion to work out") + exit(1) + end + + options.deep_merge!(ignore: {missing: {policy_groups: true}}) if SCR.get_arg("-ignore-missing-policy-groups") + + end + desc = "Restores the people manager by using a backup.json file" cases.add("-restore-db-from", :sync, desc, case_name: "restore-db") do |input, people, session, options| unless input && input.is_a?(Eco::API::Organization::People) file = SCR.get_file("-restore-db-from", required: true) input = Eco::API::Organization::People.new(JSON.parse(File.read(file)))