2025-06-24 20:27:06 +02:00
|
|
|
pub mod clean;
|
2025-06-16 16:46:22 +02:00
|
|
|
pub mod index;
|
|
|
|
|
pub mod list;
|
2025-06-24 20:27:06 +02:00
|
|
|
pub mod scan;
|
2025-06-16 16:46:22 +02:00
|
|
|
|
|
|
|
|
use crate::cli::Commands;
|
2025-06-23 20:59:49 +02:00
|
|
|
use crate::errors::NyxResult;
|
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;
|
2025-06-24 20:27:06 +02:00
|
|
|
use std::path::Path;
|
2025-06-16 16:46:22 +02:00
|
|
|
|
|
|
|
|
pub fn handle_command(
|
|
|
|
|
command: Commands,
|
|
|
|
|
database_dir: &Path,
|
2025-06-24 20:27:06 +02:00
|
|
|
config: &mut Config,
|
2025-06-23 20:59:49 +02:00
|
|
|
) -> NyxResult<()> {
|
2025-06-16 16:46:22 +02:00
|
|
|
match command {
|
2025-06-24 20:27:06 +02:00
|
|
|
Commands::Scan {
|
|
|
|
|
path,
|
|
|
|
|
no_index,
|
|
|
|
|
rebuild_index,
|
|
|
|
|
format,
|
|
|
|
|
high_only,
|
|
|
|
|
} => {
|
|
|
|
|
if high_only {
|
|
|
|
|
config.scanner.min_severity = Severity::High
|
|
|
|
|
};
|
|
|
|
|
|
2025-06-23 16:51:39 +02:00
|
|
|
scan::handle(&path, no_index, rebuild_index, format, database_dir, config)
|
2025-06-16 16:46:22 +02:00
|
|
|
}
|
2025-06-24 20:27:06 +02:00
|
|
|
Commands::Index { action } => index::handle(action, database_dir, config),
|
|
|
|
|
Commands::List { verbose } => list::handle(verbose, database_dir),
|
|
|
|
|
Commands::Clean { project, all } => clean::handle(project, all, database_dir),
|
2025-06-16 16:46:22 +02:00
|
|
|
}
|
2025-06-24 20:27:06 +02:00
|
|
|
}
|