2025-06-16 16:46:22 +02:00
|
|
|
pub mod scan;
|
|
|
|
|
pub mod index;
|
|
|
|
|
pub mod list;
|
|
|
|
|
pub mod clean;
|
|
|
|
|
|
|
|
|
|
use crate::cli::Commands;
|
|
|
|
|
use std::path::Path;
|
2025-06-23 16:51:39 +02:00
|
|
|
use crate::patterns::Severity;
|
2025-06-16 16:46:22 +02:00
|
|
|
use crate::utils::config::Config;
|
|
|
|
|
|
|
|
|
|
pub fn handle_command(
|
|
|
|
|
command: Commands,
|
|
|
|
|
database_dir: &Path,
|
2025-06-23 16:51:39 +02:00
|
|
|
config: &mut Config
|
2025-06-16 16:46:22 +02:00
|
|
|
) -> Result<(), Box<dyn std::error::Error>> {
|
|
|
|
|
match command {
|
|
|
|
|
Commands::Scan { path, no_index, rebuild_index, format, high_only } => {
|
2025-06-23 16:51:39 +02:00
|
|
|
if high_only { config.scanner.min_severity = Severity::High };
|
|
|
|
|
|
|
|
|
|
scan::handle(&path, no_index, rebuild_index, format, database_dir, config)
|
2025-06-16 16:46:22 +02:00
|
|
|
}
|
|
|
|
|
Commands::Index { action } => {
|
2025-06-17 17:42:41 +02:00
|
|
|
index::handle(action, database_dir, config)
|
2025-06-16 16:46:22 +02:00
|
|
|
}
|
|
|
|
|
Commands::List { verbose } => {
|
|
|
|
|
list::handle(verbose, database_dir)
|
|
|
|
|
}
|
|
|
|
|
Commands::Clean { project, all } => {
|
|
|
|
|
clean::handle(project, all, database_dir)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|