pub fn run(db: Option<&str>) -> anyhow::Result<()> {
    let db_url = db
        .map(|s| s.to_owned())
        .or_else(|| std::env::var("DATABASE_URL").ok())
        .ok_or_else(|| {
            anyhow::anyhow!("DATABASE_URL not set — pass --db <URL> or set DATABASE_URL in .env")
        })?;

    let rt = tokio::runtime::Runtime::new()?;
    rt.block_on(crate::tui::run(&db_url))?;
    Ok(())
}
