use crate::detect::detect_project;
use crate::{daemon_base_url, print_index_header, resolve_index, run_reindex};
use anyhow::Result;
pub async fn handle_reindex(
explicit_index: &Option<String>,
path: Option<std::path::PathBuf>,
) -> Result<()> {
let (index_id, warned) = resolve_index(explicit_index);
print_index_header(&index_id, warned);
crate::commands::daemon_guard::ensure_daemon_running_or_exit(&daemon_base_url()).await;
let reindex_path = path.unwrap_or_else(|| {
let cwd = std::env::current_dir().unwrap_or_default();
detect_project(&cwd).root_path
});
run_reindex(&index_id, &reindex_path).await
}