use std::collections::HashMap;
use anyhow::Context;
use arora_simple_data_store::SimpleDataStore;
use arora_types::data::DataStore;
use clap::Parser;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let cli = arora::DeviceCli::parse();
let store = SimpleDataStore::new();
if cli.open {
store
.set_prefix_meta(HashMap::from([(
String::new(),
arora_types::data::KeyMeta::new().editable(),
)]))
.context("the store keeps key meta")?;
}
let mut builder = arora::Arora::builder()
.with_data_store(Box::new(store))
.with_frontend(arora::standard_frontend());
for module in cli.modules()? {
builder = builder.with_module(module.header, module.executable);
}
if let Some(path) = cli.groot {
let xml = std::fs::read_to_string(&path)
.with_context(|| format!("could not read Groot file {}", path.display()))?;
arora_behavior_tree::schema_groot::BehaviorTree::try_from_groot_xml(&xml)
.map_err(|e| anyhow::anyhow!("Groot file {} does not parse: {e:?}", path.display()))?;
builder = builder.with_groot(xml);
}
builder.run().await
}