Skip to main content

oxibrain_cli/cmd/
entity_alias.rs

1use oxibrain::Brain;
2use oxibrain::BrainConfig;
3use oxibrain_store::project::{Declaration, EntityRef};
4use std::path::Path;
5
6pub async fn run(
7    dir: &Path,
8    surface: &str,
9    ty: &str,
10    alias: &str,
11    space: &str,
12) -> anyhow::Result<()> {
13    let brain = Brain::open(BrainConfig::at(dir)).await?;
14    let space_id = brain.ensure_space(space).await?;
15    let decl = Declaration::Alias {
16        entity: EntityRef {
17            surface: surface.to_string(),
18            ty: ty.to_string(),
19        },
20        surface: alias.to_string(),
21    };
22    let ep_id = brain.declare(&space_id, decl).await?;
23    println!("alias added as episode: {ep_id}");
24    Ok(())
25}