use std::collections::HashMap;
use std::rc::Rc;
use anyhow::Context;
use arora_simple_data_store::SimpleDataStore;
use clap::Parser;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let cli = arora::DeviceCli::parse();
let mut builder = arora::Arora::builder();
if let Some(path) = cli.groot {
let xml = std::fs::read_to_string(&path)
.with_context(|| format!("could not read Groot file {}", path.display()))?;
let store = SimpleDataStore::new();
let mut tree = arora::BehaviorTreeInterpreter::new(Rc::new(HashMap::new()));
tree.load_groot(&xml, &store).map_err(|e| {
anyhow::anyhow!(
"failed to install behavior tree from {}: {e:?}",
path.display()
)
})?;
builder = builder
.with_data_store(Box::new(store))
.with_behavior_interpreter(Box::new(tree));
}
builder.run().await
}