Skip to main content

oxibrain_cli/cmd/
source_policy.rs

1use oxibrain::Brain;
2use oxibrain::BrainConfig;
3use oxibrain_store::project::Declaration;
4use std::path::Path;
5
6pub async fn run(
7    dir: &Path,
8    name: &str,
9    trust: &str,
10    effective_from: Option<i64>,
11    effective_to: Option<i64>,
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 now = brain.clock_now();
17    let decl = Declaration::SetSourcePolicy {
18        source_name: name.to_string(),
19        trust: trust.to_string(),
20        effective_from: effective_from.unwrap_or(now.millis()),
21        effective_to,
22    };
23    let ep_id = brain.declare(&space_id, decl).await?;
24    println!("policy set as episode: {ep_id}");
25    Ok(())
26}