todotxt_rs 0.1.1

A fast, lightweight parser for the todo.txt file format.
Documentation
use anyhow::Context;
use clap::Parser;
use std::fs::File;
use std::io::{BufRead, BufReader};
use std::path::PathBuf;
use todotxt_rs::parse_line;

#[derive(Parser, Debug)]
#[command(
    version,
    about = "A CLI tool for parsing todo.txt files.", // 'credits'
    long_about = "Parses a todo.txt file and prints the recognized parts."
)]
struct Args {
    #[arg(required = true)]
    file: PathBuf,
}

fn main() -> anyhow::Result<()> {
    let args = Args::parse();

    let file = File::open(&args.file)
        .with_context(|| format!("Не вдалося відкрити файл: {:?}", &args.file))?;

    let reader = BufReader::new(file);

    println!("--- Початок парсингу файлу: {:?} ---", &args.file);

    for (index, line_result) in reader.lines().enumerate() {
        let line =
            line_result.with_context(|| format!("Не вдалося прочитати рядок {}", index + 1))?;
        match parse_line(&line) {
            Ok(task) => {
                println!("[Рядок {}]: {:?}", index + 1, task);
            }
            Err(e) => {
                println!("[Рядок {}]: ПОМИЛКА ПАРСИНГУ: {}", index + 1, e);
            }
        }
    }

    println!("--- Парсинг завершено ---");
    Ok(())
}