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
def main()Entry point for the predraw CLI.
#_cmd_build
def _cmd_build(ctx, path: str) -> NoneBuild all outputs for a scene, grouped by mode to avoid redundant work.
#_build
def _build(path: str, *, dry_run: bool) -> intThe 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
def _cmd_pack(ctx, path: str, *, output: str) -> NonePack a scene directory into a single self-contained JSON file.
#_cmd_unpack
def _cmd_unpack(ctx, file: str, *, output: str) -> NoneUnpack a packed JSON file into a project directory.
#_cmd_init
def _cmd_init(ctx, path: str) -> NoneCreate a starter predraw project in the given directory.
#_collect_json_files
def _collect_json_files(project_dir: Path) -> list[Path]Collect all .json files in the project directory, excluding *.local-only dirs.
#_get_mtimes
def _get_mtimes(files: list[Path]) -> dict[Path, float]Get mtime for each file, skipping files that disappeared.
#_detect_changes
def _detect_changes(prev_mtimes: dict[Path, float], curr_mtimes: dict[Path, float]) -> boolReturn True if any files were added, removed, or modified.
#_cmd_watch
def _cmd_watch(ctx, path: str) -> NoneWatch project files and rebuild on change.
#_cmd_validate
def _cmd_validate(ctx, file: str, *, schema: str) -> NoneValidate a JSON file against its scene or config schema.
#pack_scene
def pack_scene(scene: Scene) -> dictConvert 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
def _assign_ids(elements: list[dict], counter: list[int] | None=None) -> NoneRecursively assign auto-generated IDs to elements missing one.
#unpack_scene
def unpack_scene(scene: Scene, output_dir: str) -> NoneUnpack a scene into a directory structure with components/ and main.json.
#_scene_to_dict
def _scene_to_dict(scene: Scene) -> dictConvert a Scene back to a JSON-serializable dict.
#_element_to_dict
def _element_to_dict(el: Element) -> dictConvert an Element back to a JSON-serializable dict.
Omits default/None values to keep output clean.
#_gradient_to_dict
def _gradient_to_dict(grad: Gradient) -> dictConvert a Gradient to a JSON-serializable dict, omitting defaults.
#_char_style_to_dict
def _char_style_to_dict(cs) -> dictConvert a CharStyle to a dict, omitting defaults.