use std::path::Path;
use anyhow::Result;
use crate::config::Config;
use crate::project::ProjectLayout;
use crate::store::hierarchy::Hierarchy;
use crate::store::Store;
mod app;
mod session;
pub use app::LinguisticApp;
#[derive(Debug, Default)]
pub struct LinguisticInvocation {
pub language: Option<String>,
pub session: Option<String>,
}
pub(crate) fn run(project: &Path, inv: LinguisticInvocation) -> Result<()> {
let layout = ProjectLayout::new(project);
layout.require_initialized().map_err(anyhow::Error::from)?;
let cfg = Config::load_layered(&layout.config_path()).map_err(anyhow::Error::from)?;
let store = Store::open(layout.clone(), &cfg).map_err(anyhow::Error::from)?;
let hierarchy = Hierarchy::load(&store).map_err(anyhow::Error::from)?;
launch_tui(layout, cfg, store, hierarchy, inv)
}
fn launch_tui(
layout: ProjectLayout,
cfg: Config,
store: Store,
hierarchy: Hierarchy,
inv: LinguisticInvocation,
) -> Result<()> {
crate::tui_host::with_terminal(|terminal| {
let mut app = LinguisticApp::new(layout, cfg, store, hierarchy, inv)?;
app.run(terminal)
})
}