oxibrain_cli/cmd/export_cmd.rs
1use oxibrain::{Brain, BrainConfig};
2use std::path::{Path, PathBuf};
3
4pub async fn run(dir: &Path, out: Option<PathBuf>) -> anyhow::Result<()> {
5 let brain = Brain::open(BrainConfig::at(dir)).await?;
6 let jsonl = brain.export_jsonl().await?;
7 match out {
8 Some(path) => {
9 std::fs::write(&path, jsonl.as_bytes())?;
10 println!("wrote {} bytes to {}", jsonl.len(), path.display());
11 }
12 None => {
13 println!("{jsonl}");
14 }
15 }
16 Ok(())
17}