codact 0.1.1

solutions to advent of code
Documentation
use std::io;

use clap::{Command, Parser};
use clap_complete::{Generator, Shell, generate};

use crate::event;

#[derive(Debug, Parser)]
#[command(author, version, about, long_about = None)]
#[command(help_template = "\
{before-help}{name} {version}

{about-with-newline}
{usage-heading} {usage}

{all-args}{after-help}

{author-with-newline}
")]
#[command(next_line_help = true)]
#[command(term_width = 0)]
/// Collection of solutions for advent of code
///
/// Compiled as a cli that takes the day in the event
/// and the year the event took place, then returns a
/// the solution to this day.
///
/// # Examples
///
/// You can parse command line arguments using
///
/// ```rust
/// let cli = Cli::parse();
/// ```
///
pub struct Cli {
    /// The day of the event
    #[arg(short, long, value_enum, default_value_t)]
    pub day: event::Day,

    /// The year of the event
    #[arg(short, long, value_enum, default_value_t)]
    pub year: event::Year,

    /// Generate shell completion
    #[arg(short, long, value_enum, conflicts_with_all = ["day", "year"]) ]
    pub completion: Option<Shell>,

    #[arg(long)]
    pub man: Option<bool>,
}

impl Cli {
    pub fn print_completion<G: Generator>(generator: G, cmd: &mut Command) {
        generate(
            generator,
            cmd,
            cmd.get_name().to_string(),
            &mut io::stdout(),
        );
    }
}

#[cfg(test)]
mod test {
    use clap::CommandFactory;

    use super::Cli;

    #[test]
    fn verify_cli() {
        Cli::command().debug_assert();
    }
}