predraw v0.3.0 /predraw.cli
On this page

CLI entry point for predraw — strictcli-based with build/pack/unpack subcommands.

#predraw.cli

#predraw.cli

CLI entry point for predraw — strictcli-based with build/pack/unpack subcommands.

#main

python
def main()

Entry point for the predraw CLI.

#_cmd_build

python
def _cmd_build(ctx, path: str) -> None

Build all outputs for a scene, grouped by mode to avoid redundant work.

#_build

python
def _build(path: str, *, dry_run: bool) -> int

The build itself, callable without a strictcli Context.

Split out of the handler because watch rebuilds by calling it directly and because --dry-run is now framework-owned: the flag arrives on the Context (ctx.dry_run), never as a handler kwarg, so the one parameter that actually varies has to be passed explicitly here.

#_cmd_pack

python
def _cmd_pack(ctx, path: str, *, output: str) -> None

Pack a scene directory into a single self-contained JSON file.

#_cmd_unpack

python
def _cmd_unpack(ctx, file: str, *, output: str) -> None

Unpack a packed JSON file into a project directory.

#_cmd_init

python
def _cmd_init(ctx, path: str) -> None

Create a starter predraw project in the given directory.

#_collect_json_files

python
def _collect_json_files(project_dir: Path) -> list[Path]

Collect all .json files in the project directory, excluding *.local-only dirs.

#_get_mtimes

python
def _get_mtimes(files: list[Path]) -> dict[Path, float]

Get mtime for each file, skipping files that disappeared.

#_detect_changes

python
def _detect_changes(prev_mtimes: dict[Path, float], curr_mtimes: dict[Path, float]) -> bool

Return True if any files were added, removed, or modified.

#_cmd_watch

python
def _cmd_watch(ctx, path: str) -> None

Watch project files and rebuild on change.

#_cmd_validate

python
def _cmd_validate(ctx, file: str, *, schema: str) -> None

Validate a JSON file against its scene or config schema.

#pack_scene

python
def pack_scene(scene: Scene) -> dict

Convert a Scene to a packed JSON-serializable dict.

Removes imports (already resolved into defs) and assigns IDs to elements that lack them for referenceability.

#_assign_ids

python
def _assign_ids(elements: list[dict], counter: list[int] | None=None) -> None

Recursively assign auto-generated IDs to elements missing one.

#unpack_scene

python
def unpack_scene(scene: Scene, output_dir: str) -> None

Unpack a scene into a directory structure with components/ and main.json.

#_scene_to_dict

python
def _scene_to_dict(scene: Scene) -> dict

Convert a Scene back to a JSON-serializable dict.

#_element_to_dict

python
def _element_to_dict(el: Element) -> dict

Convert an Element back to a JSON-serializable dict.

Omits default/None values to keep output clean.

#_gradient_to_dict

python
def _gradient_to_dict(grad: Gradient) -> dict

Convert a Gradient to a JSON-serializable dict, omitting defaults.

#_char_style_to_dict

python
def _char_style_to_dict(cs) -> dict

Convert a CharStyle to a dict, omitting defaults.

Search