feat: add CLI dispatcher and work config loader

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
dasemuandClaude Opus 5.5 committed 2026-10-17 09:42:44 +02:00
1 parent 9be73dadac
commit 10af4346f6
3 files changed
+75

No files matched your search

+2
View File
@@ -6,3 +6,5 @@ Recurring problems and what worked. Read before starting; add an entry when a mi
(`git remote add`) must run outside the sandbox.
- `~/.cache/uv` is read-only inside the sandbox: export `UV_CACHE_DIR=$TMPDIR/uv-cache`
before any `uv` command.
- The sandbox mounts char-device placeholders (`.claude/`, `.mcp.json`, dotfiles) in the
working dir; they are gitignored, never `git add` them.
+36
View File
@@ -0,0 +1,36 @@
"""Command-line entry point.
Each pipeline stage lives in its own module exposing ``register(subparsers)``,
which adds a subcommand whose handler takes the parsed ``argparse.Namespace``.
"""
import argparse
import importlib
from pathlib import Path
STAGE_MODULES = ["text", "annotate", "assets", "renpy_gen"]
def main(argv: list[str] | None = None) -> int:
parser = argparse.ArgumentParser(prog="vnpipe", description=__doc__)
parser.add_argument(
"--work",
type=Path,
default=Path("works/faust"),
help="Work directory containing work.toml (default: works/faust)",
)
sub = parser.add_subparsers(dest="command", required=True)
for name in STAGE_MODULES:
try:
module = importlib.import_module(f"vnpipe.{name}")
except ModuleNotFoundError as exc:
if exc.name != f"vnpipe.{name}":
raise
continue
module.register(sub)
args = parser.parse_args(argv)
return args.handler(args) or 0
if __name__ == "__main__":
raise SystemExit(main())
+37
View File
@@ -0,0 +1,37 @@
"""Load a work's configuration (works/<id>/work.toml)."""
import tomllib
from dataclasses import dataclass
from pathlib import Path
from typing import Any
@dataclass(frozen=True)
class Work:
root: Path
data: dict[str, Any]
@property
def id(self) -> str:
return self.data["work"]["id"]
@property
def cast(self) -> dict[str, dict[str, Any]]:
return self.data["cast"]
@property
def speakers(self) -> dict[str, str]:
return self.data["speakers"]
@property
def scenes(self) -> list[dict[str, Any]]:
return self.data["scenes"]
def path(self, relative: str) -> Path:
return self.root / relative
def load_work(root: Path) -> Work:
root = Path(root)
with (root / "work.toml").open("rb") as fh:
return Work(root=root, data=tomllib.load(fh))