oxibrain_cli/cmd/
entity_merge.rs1use oxibrain::Brain;
2use oxibrain::BrainConfig;
3use oxibrain_store::project::{Declaration, EntityRef};
4use std::path::Path;
5
6pub async fn run(
7 dir: &Path,
8 loser: &str,
9 loser_type: &str,
10 winner: &str,
11 winner_type: &str,
12 space: &str,
13) -> anyhow::Result<()> {
14 let brain = Brain::open(BrainConfig::at(dir)).await?;
15 let space_id = brain.ensure_space(space).await?;
16 let decl = Declaration::Merge {
17 loser: EntityRef {
18 surface: loser.to_string(),
19 ty: loser_type.to_string(),
20 },
21 winner: EntityRef {
22 surface: winner.to_string(),
23 ty: winner_type.to_string(),
24 },
25 };
26 let ep_id = brain.declare(&space_id, decl).await?;
27 println!("merged as episode: {ep_id}");
28 Ok(())
29}