vyctor 0.1.0

A fast CLI tool for semantic file search using vector embeddings
Documentation
//! CLI command implementations

pub mod browse;
pub mod config_cmd;
pub mod init;
pub mod lookup;
pub mod status;
pub mod sync;
pub mod watch;

use crate::config::VyctorConfig;
use crate::daemon::{is_daemon_running, log_file_path, start_daemon};
use anyhow::Result;
use colored::Colorize;
use std::path::Path;

/// Ensure the daemon is running if auto_start is enabled in config
///
/// This is called by init, sync, and lookup commands to auto-start the daemon.
/// Returns Ok(()) silently if daemon is already running or auto_start is disabled.
pub fn ensure_daemon_running(root: &Path, config: &VyctorConfig) -> Result<()> {
    // Check if auto_start is enabled
    if !config.watch.auto_start {
        return Ok(());
    }

    // Check if already running
    if is_daemon_running(root).is_some() {
        return Ok(());
    }

    // Start the daemon
    match start_daemon(root, config.watch.debounce_ms) {
        Ok(pid) => {
            println!("{} Started watcher daemon (PID {})", "".cyan(), pid);
            println!("  Log file: {}", log_file_path(root).display());
            Ok(())
        }
        Err(e) => {
            // Don't fail the main command if daemon fails to start
            eprintln!("{} Could not start watcher daemon: {}", "!".yellow(), e);
            Ok(())
        }
    }
}