grrs-tutorial 0.1.0

Basic implementation of this tutorial: https://rust-cli.github.io/book/
Documentation
// https://rust-cli.github.io/book/tutorial/
// Ah, 'grrs' is a portmanteau of 'grep' and 'rust'
use clap::Parser;
use anyhow::{Context, Result};

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

// This is for the possible exit in with_context... which'd return an error?
// And so since that cooould return an anyhow::Result, we need to return one of those
// through all paths, hence the Ok(()).
// This is all so we don't need to panic, we just return the error.
fn main() -> Result<()> {
    let args = Cli::parse();

    // a BufReader would be better here
    let content = std::fs::read_to_string(&args.path)
    .with_context(|| format!("could not read file `{}`", args.path.display()))?;

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

    Ok(())
}