aoc-toolkit 0.1.0-alpha.3

A toolkit for solving Advent of Code problems
Documentation
use clap::Args;

use crate::application::fetch::{self, FetchOptions};
use crate::cli::error::CliError;
use crate::cli::output::fetch::print_fetch_report;

#[derive(Debug, Args)]
pub struct FetchArgs {
    /// Advent of Code year
    #[arg(short, long)]
    year: Option<usize>,

    /// Puzzle day
    #[arg(short, long)]
    day: Option<usize>,

    /// Fetch all unlocked puzzles for the selected year
    #[arg(long, conflicts_with = "day")]
    all: bool,
}

pub(crate) fn execute(args: &FetchArgs) -> Result<bool, CliError> {
    let reports = fetch::execute(&FetchOptions {
        year: args.year,
        day: args.day,
        all: args.all,
    })?;

    print_fetch_report(&reports, args.all);

    Ok(reports.iter().all(|report| report.outcome.is_ok()))
}