"CLI-Anything: Making ALL Software Agent-Native" -- CLI-Hub: https://clianything.cc/
Python
fix(inkscape): autosave new documents to project path (#430)
PP1853f6d63f90d
diff --git a/inkscape/agent-harness/cli_anything/inkscape/inkscape_cli.py b/inkscape/agent-harness/cli_anything/inkscape/inkscape_cli.pyindex f2f0cb0ad..1f0ea5d21 100644--- a/inkscape/agent-harness/cli_anything/inkscape/inkscape_cli.py+++ b/inkscape/agent-harness/cli_anything/inkscape/inkscape_cli.py@@ -207,9 +207,12 @@ def document_new(width, height, units, background, name, profile, output):background=background, name=name, profile=profile,)sess = get_session()- sess.set_project(proj, output)+ auto_save_path = sess.project_path if _auto_save and not _dry_run else None+ sess.set_project(proj, output or auto_save_path)if output:doc_mod.save_document(proj, output)+ elif auto_save_path:+ sess.save_session()output_data = doc_mod.get_document_info(proj)globals()["output"](output_data, f"Created document: {name}")diff --git a/inkscape/agent-harness/cli_anything/inkscape/tests/test_full_e2e.py b/inkscape/agent-harness/cli_anything/inkscape/tests/test_full_e2e.pyindex a0ad8109f..e2abe17ce 100644--- a/inkscape/agent-harness/cli_anything/inkscape/tests/test_full_e2e.py+++ b/inkscape/agent-harness/cli_anything/inkscape/tests/test_full_e2e.py@@ -729,6 +729,29 @@ class TestCLISubprocess:assert result.returncode == 0assert os.path.exists(out)+ def test_document_new_autosaves_to_project_path(self, tmp_dir):+ out = os.path.join(tmp_dir, "autosaved.json")+ result = self._run([+ "--project", out, "--save", "document", "new",+ "--name", "autosaved", "--width", "720", "--height", "960",+ ])++ assert result.returncode == 0+ with open(out, encoding="utf-8") as project_file:+ project = json.load(project_file)+ assert project["name"] == "autosaved"+ assert project["document"]["width"] == 720+ assert project["document"]["height"] == 960++ def test_document_new_autosave_respects_dry_run(self, tmp_dir):+ out = os.path.join(tmp_dir, "dry-run.json")+ result = self._run([+ "--project", out, "--save", "--dry-run", "document", "new",+ ])++ assert result.returncode == 0+ assert not os.path.exists(out)+def test_document_new_json_output(self, tmp_dir):out = os.path.join(tmp_dir, "test.json")result = self._run(["--json", "document", "new", "-o", out])