Save and reopen native Beta source snapshots

This commit is contained in:
gloamxun committed 2026-11-29 13:30:18 +08:00
1 parent 9841e88900
commit 29193c03bc
7 files changed
+198 -11

No files matched your search

+17 -5
View File
@@ -125,9 +125,18 @@ def launch(args):
env.update(manifest["environment"])
env["TEXRRA_STATE_DIR"] = str(bundle / "state")
profile = manifest["input_profile"]
if args.action == "open":
source = args.entry.resolve(strict=True) if args.entry else bundle / "a4-project/main.tex"
assets = args.file if args.entry else ["chapter.tex", *args.file]
if args.action in ("open", "resume"):
if args.action == "resume":
saved = args.snapshot.resolve(strict=True)
project = json.loads((saved / "project.json").read_text(encoding="utf-8"))
entry = Path(project["entry"])
if len(entry.parts) != 1 or entry.name in ("", ".."):
raise ValueError("The saved project entry must be a filename")
source = (saved / "sources" / entry).resolve(strict=True)
assets = project["files"]
else:
source = args.entry.resolve(strict=True) if args.entry else bundle / "a4-project/main.tex"
assets = args.file if args.entry else ["chapter.tex", *args.file]
runs = bundle / "runs"
if args.run_dir:
run = args.run_dir.resolve()
@@ -162,8 +171,11 @@ def main():
editor = commands.add_parser("open", help="open a project or the bundled A4 sample")
editor.add_argument("entry", type=Path, nargs="?")
editor.add_argument("--file", action="append", default=[], help="path relative to the entry")
editor.add_argument("--run-dir", type=Path)
editor.add_argument("--port", type=int, default=0)
resume = commands.add_parser("resume", help="reopen a saved source snapshot")
resume.add_argument("snapshot", type=Path)
for command in (editor, resume):
command.add_argument("--run-dir", type=Path)
command.add_argument("--port", type=int, default=0)
compiler = commands.add_parser("compile", help="produce a PDF with the bundle's native CLI")
compiler.add_argument("entry", type=Path)