opengrep 1.1.0

Advanced AST-aware code search tool with tree-sitter parsing and AI integration capabilities
Documentation
//! Example showing custom configuration usage

use opengrep::{search::SearchEngine, Config, SearchConfig, OutputConfig};
use std::path::PathBuf;

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    // Create custom configuration
    let config = Config {
        search: SearchConfig {
            ignore_case: true,
            regex: true,
            follow_symlinks: false,
            max_depth: Some(3),
            max_file_size: Some(1024 * 1024), // 1MB
            threads: 4,
            hidden: false,
            respect_gitignore: true,
        },
        output: OutputConfig {
            color: true,
            line_numbers: true,
            before_context: 3,
            after_context: 3,
            show_ast_context: true,
            max_ast_depth: 2,
            highlight: true,
        },
        #[cfg(feature = "ai")]
        ai: None,
    };
    
    // Save configuration to file
    config.save_to_file("opengrep.toml")?;
    println!("Configuration saved to opengrep.toml");
    
    // Load configuration from file
    let loaded_config = Config::from_file("opengrep.toml")?;
    println!("Configuration loaded from file");
    
    // Create search engine with custom config
    let engine = SearchEngine::new(loaded_config);
    
    // Perform search with custom settings
    let results = engine.search(r"pub\s+(fn|struct|enum)", &[PathBuf::from("src")]).await?;
    
    println!("\nFound {} files with public items:", results.len());
    
    for result in results {
        println!("\n{} ({} matches)", 
            result.path.display(),
            result.matches.len()
        );
        
        for match_item in result.matches.iter().take(3) {
            println!("   {}:{} - {}", 
                match_item.line_number,
                match_item.column_range.start,
                match_item.line_text.trim()
            );
        }
        
        if result.matches.len() > 3 {
            println!("   ... and {} more matches", result.matches.len() - 3);
        }
    }
    
    // Clean up
    std::fs::remove_file("opengrep.toml").ok();
    
    Ok(())
}