use std::path::PathBuf;
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum OutputMode {
Content,
FilesWithMatches,
Count,
}
impl OutputMode {
pub fn from_str(s: &str) -> Result<Self, String> {
match s {
"content" => Ok(Self::Content),
"files_with_matches" => Ok(Self::FilesWithMatches),
"count" => Ok(Self::Count),
_ => Err(format!(
"Invalid output_mode '{}'. Use 'content', 'files_with_matches', or 'count'.",
s
)),
}
}
}
#[derive(Clone, Debug)]
pub struct LineMatch {
pub line_number: u64,
pub content: String,
}
#[derive(Clone, Debug)]
pub struct FileMatch {
pub path: PathBuf,
pub line_matches: Vec<LineMatch>,
pub context_lines: Vec<(u64, String)>,
pub match_count: usize,
}