rohit_grep 0.1.0

A tool to search files
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use clap::Parser;
use anyhow::{Context, Result};

#[derive(Parser)]
struct Cli {
    pattern: String,
    path: std::path::PathBuf,
}

fn main() -> Result<()>{
    let args = Cli::parse();
    let content = std::fs::read_to_string(&args.path)
    .with_context(|| format!("could not read file `{}`", args.path.display()))?;

    rohit_grep::find_matches(&content,& args.pattern, &mut std::io::stdout());

    return Ok(());
}