concinnity-dev 0.19.119

The Concinnity dev tooling library: world authoring, the in-engine editor, the debug server, docs and packaging
//! Discovery wrapper around `crate::authoring::add_to_path`.
//!
//! The CLI binary handles world-path discovery: try the standard `worlds/`
//! location first, then fall back to `world.jsonl` in cwd. When the fallback is
//! hit and the target is a 3D scene (.glb), `add_to_path` scaffolds a fresh
//! world at that location.

use concinnity_cook::authoring::world::WORLD_JSONL;

use crate::authoring::add_to_path;
use crate::command::discover_world_path;

/// Create an asset from `target` and apply it to the discovered world.
///
/// Tries `worlds/` first, then `world.jsonl` in the working
/// directory; when neither exists and the target is a 3D scene, the world is
/// scaffolded at the fallback location.
pub fn add(name: Option<&str>, target: &str, template: Option<&str>) -> std::io::Result<()> {
    let world_path = match discover_world_path() {
        Ok(p) => p,
        Err(e) if e.kind() == std::io::ErrorKind::NotFound => WORLD_JSONL.to_string(),
        Err(e) => return Err(e),
    };
    add_to_path(&world_path, name, target, template)
}