Merge pull request #112 from sehawq/fix/gimp-cli-session-persistence

fix: persist session state in CLI mode and handle quoted text in REPL
This commit is contained in:
Yuhao
2026-03-20 19:40:48 +08:00
committed by GitHub

View File

@@ -18,6 +18,7 @@ Usage:
import sys
import os
import json
import shlex
import click
from typing import Optional
@@ -136,6 +137,15 @@ def cli(ctx, use_json, project_path):
ctx.invoke(repl, project_path=None)
@cli.result_callback()
def auto_save_on_cli(result, **kwargs):
"""Auto-save project after CLI commands when --project is specified."""
if not _repl_mode:
sess = get_session()
if sess.has_project() and sess._modified and sess.project_path:
proj_mod.save_project(sess.get_project(), sess.project_path)
# ── Project Commands ─────────────────────────────────────────────
@cli.group()
def project():
@@ -761,8 +771,11 @@ def repl(project_path):
skin.help(_repl_commands)
continue
# Parse and execute command
args = line.split()
# Parse and execute command (shlex handles quoted strings with spaces)
try:
args = shlex.split(line)
except ValueError:
args = line.split()
try:
cli.main(args, standalone_mode=False)
except SystemExit: