"CLI-Anything: Making ALL Software Agent-Native" -- CLI-Hub: https://clianything.cc/
Python
fix(inkscape): add -s/--save flag for auto-save in one-shot mode (fixes #182)
Octopusc1e5d4f195ad
diff --git a/inkscape/agent-harness/cli_anything/inkscape/inkscape_cli.py b/inkscape/agent-harness/cli_anything/inkscape/inkscape_cli.pyindex 1a694f1d0..89ff0a068 100644--- a/inkscape/agent-harness/cli_anything/inkscape/inkscape_cli.py+++ b/inkscape/agent-harness/cli_anything/inkscape/inkscape_cli.py@@ -39,6 +39,7 @@ from cli_anything.inkscape.core import export as export_mod_session: Optional[Session] = None_json_output = False_repl_mode = False+_auto_save = Falsedef get_session() -> Session:@@ -120,14 +121,20 @@ def handle_error(func):@click.option("--json", "use_json", is_flag=True, help="Output as JSON")@click.option("--project", "project_path", type=str, default=None,help="Path to .inkscape-cli.json project file")[email protected]("-s", "--save", "auto_save", is_flag=True,+ help="Auto-save project after each mutation command (one-shot mode)")@click.pass_context-def cli(ctx, use_json, project_path):+def cli(ctx, use_json, project_path, auto_save):"""Inkscape CLI — Stateful vector graphics editing from the command line.Run without a subcommand to enter interactive REPL mode.++ Use -s/--save to automatically save changes after each mutation command.+ This is useful in one-shot mode where each command runs in a new process."""- global _json_output+ global _json_output, _auto_save_json_output = use_json+ _auto_save = auto_saveif project_path:sess = get_session()@@ -135,10 +142,26 @@ def cli(ctx, use_json, project_path):proj = doc_mod.open_document(project_path)sess.set_project(proj, project_path)+ # Register auto-save callback to run after each command+ ctx.call_on_close(_auto_save_callback)+if ctx.invoked_subcommand is None:ctx.invoke(repl, project_path=None)+def _auto_save_callback():+ """Auto-save callback that runs after each command."""+ global _auto_save, _session+ if _auto_save and _session and _session.has_project() and _session._modified:+ # Don't auto-save if we're in REPL mode (user can explicitly save)+ if not _repl_mode:+ try:+ saved = _session.save_session()+ click.echo(f"Auto-saved to: {saved}")+ except Exception as e:+ click.echo(f"Auto-save failed: {e}", err=True)++# ── Document Commands ───────────────────────────────────────────@cli.group()def document():