mirror of
https://github.com/elicpeter/nyx.git
synced 2026-06-21 20:18:06 +02:00
- Added `tracing-appender` and `log` dependencies to improve error logging. - Enhanced `walk.rs` to add error handling with warning logs for ignore patterns. - Expanded Rust and JavaScript patterns with additional security vulnerability checks. - Simplified and updated pattern queries for improved accuracy and consistency. - Removed unused print statement in `index.rs`.
47 lines
No EOL
1.6 KiB
Rust
47 lines
No EOL
1.6 KiB
Rust
use std::fs;
|
|
use crate::cli::IndexAction;
|
|
use crate::utils::project::get_project_info;
|
|
|
|
pub fn handle(
|
|
action: IndexAction,
|
|
database_dir: &std::path::Path,
|
|
) -> Result<(), Box<dyn std::error::Error>> {
|
|
match action {
|
|
IndexAction::Build { path, force } => {
|
|
let build_path = std::path::Path::new(&path).canonicalize()?;
|
|
let (project_name, db_path) = get_project_info(&build_path, database_dir)?;
|
|
|
|
if force || !db_path.exists() {
|
|
println!("Building index for: {}", project_name);
|
|
build_index(&build_path, &db_path)?;
|
|
println!("Index built: {}", db_path.display());
|
|
} else {
|
|
println!("Index already exists. Use --force to rebuild.");
|
|
}
|
|
}
|
|
IndexAction::Status { path } => {
|
|
let status_path = std::path::Path::new(&path).canonicalize()?;
|
|
let (project_name, db_path) = get_project_info(&status_path, database_dir)?;
|
|
|
|
println!("Project: {}", project_name);
|
|
println!("Index path: {}", db_path.display());
|
|
println!("Index exists: {}", db_path.exists());
|
|
|
|
if db_path.exists() {
|
|
let metadata = fs::metadata(&db_path)?;
|
|
println!("Index size: {} bytes", metadata.len());
|
|
println!("Last modified: {:?}", metadata.modified()?);
|
|
}
|
|
}
|
|
}
|
|
Ok(())
|
|
}
|
|
|
|
pub fn build_index(
|
|
_project_path: &std::path::Path,
|
|
db_path: &std::path::Path,
|
|
) -> Result<(), Box<dyn std::error::Error>> {
|
|
// TODO: Implement actual index building
|
|
fs::File::create(db_path)?;
|
|
Ok(())
|
|
} |