mirror of
https://github.com/elicpeter/nyx.git
synced 2026-07-12 21:02:11 +02:00
Added foundational modules for core functionalities:
- Introduced `walk.rs` as a parallel directory walker for search operations. - Implemented basic index handling in `commands/index.rs`. - Created `utils/config.rs` for configuration management with placeholders for future enhancements.
This commit is contained in:
commit
ab5558f537
16 changed files with 2187 additions and 0 deletions
53
src/commands/scan.rs
Normal file
53
src/commands/scan.rs
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
use crate::cli::OutputFormat;
|
||||
use crate::utils::project::get_project_info;
|
||||
use std::path::Path;
|
||||
use crate::utils::config::Config;
|
||||
|
||||
pub fn handle(
|
||||
path: &str,
|
||||
no_index: bool,
|
||||
rebuild_index: bool,
|
||||
format: OutputFormat,
|
||||
high_only: bool,
|
||||
database_dir: &Path,
|
||||
config: &Config,
|
||||
) -> Result<(), Box<dyn std::error::Error>> {
|
||||
let scan_path = Path::new(path).canonicalize()?;
|
||||
let (project_name, db_path) = get_project_info(&scan_path, database_dir)?;
|
||||
|
||||
tracing::info!("Config: {:?}", config);
|
||||
tracing::info!("Scanning project: {}", project_name);
|
||||
tracing::info!("Scan path: {}", scan_path.display());
|
||||
|
||||
if no_index {
|
||||
tracing::info!("Scanning without index...");
|
||||
scan_filesystem(&scan_path)?;
|
||||
} else {
|
||||
if rebuild_index || !db_path.exists() {
|
||||
tracing::info!("Building/updating index...");
|
||||
crate::commands::index::build_index(&scan_path, &db_path)?;
|
||||
}
|
||||
|
||||
tracing::info!("Using index: {}", db_path.display());
|
||||
scan_with_index(&db_path)?;
|
||||
}
|
||||
|
||||
tracing::info!("Output format: {:?}", format);
|
||||
if high_only {
|
||||
tracing::info!("Filtering: High severity only");
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn scan_filesystem(path: &Path) -> Result<(), Box<dyn std::error::Error>> {
|
||||
// TODO: Implement direct filesystem scanning
|
||||
tracing::info!("Direct filesystem scan of: {}", path.display());
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn scan_with_index(db_path: &Path) -> Result<(), Box<dyn std::error::Error>> {
|
||||
// TODO: Implement index-based scanning
|
||||
tracing::info!("Index-based scan using: {}", db_path.display());
|
||||
Ok(())
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue