Skip to main content

concinnity_dev/command/
build.rs

1use concinnity_cook::authoring::world::find_world_jsonl;
2use concinnity_cook::build_from_path;
3
4// Compile a world to binary blobs and write world-lock.json.
5// Entry point for the `cn build` CLI subcommand.
6//
7// `world` is an optional world name resolved against .concinnity/worlds/; None
8// selects the most recently modified world there, falling back to world.jsonl.
9//
10// If `server` and `user` are both provided, any source files missing from
11// .concinnity/assets/ are fetched from the server before compiling.
12/// Compile a world to binary blobs and write `world-lock.json`.
13///
14/// `json_path` is used when it names an existing file; otherwise the world is
15/// discovered.
16pub fn build(json_path: Option<&str>) -> std::io::Result<()> {
17    let resolved;
18    let json_path = match json_path {
19        Some(p) if std::path::Path::new(p).exists() => p,
20        _ => {
21            resolved = find_world_jsonl(None)?;
22            resolved.as_str()
23        }
24    };
25    build_from_path(json_path)
26}