sysmap 0.2.0

Project Mapping CLI Tool
use anyhow::Result;
use clap::Parser;
use colored::{control, Colorize};

mod cli;
mod colors;
mod commands;
mod config;
mod deps;
mod map;
mod patterns;
mod scanner;

use cli::{Cli, Commands};

fn main() {
    if let Err(e) = run() {
        eprintln!("{} {}", "error:".red().bold(), e);
        std::process::exit(1);
    }
}

fn run() -> Result<()> {
    let cli = Cli::parse();

    // Handle global flags
    if cli.no_color {
        control::set_override(false);
    }

    let verbosity = if cli.quiet { 0 } else if cli.verbose { 2 } else { 1 };

    match cli.command {
        Commands::Init { path, force } => {
            commands::init::execute(path, force, verbosity)?;
        }
        Commands::Summary { json, yaml, counts } => {
            commands::summary::execute(json, yaml, counts)?;
        }
        Commands::Tree { path, depth, all, counts } => {
            commands::tree::execute(path, depth, all, counts)?;
        }
        Commands::Update { full } => {
            commands::update::execute(full, verbosity)?;
        }
        Commands::Find { query, file_type, language, purpose, counts, deps } => {
            commands::find::execute(query, file_type, language, purpose, counts, deps)?;
        }
        Commands::Deps { file, reverse, json } => {
            commands::deps::execute(file, reverse, json)?;
        }
    }

    Ok(())
}