#advent #solution #command-line #input #utilities #builder #input-file

aoc-utils

A minimal set of utils for writing Advent of Code solutions

10 releases

0.5.0 Sep 17, 2023
0.4.3 Nov 16, 2022
0.4.2 Jun 11, 2022
0.4.1 Nov 19, 2021
0.1.1 May 27, 2020

#20 in #advent

MIT license

8KB
87 lines

Advent of Code Rust utilities

Crates.io Docs.rs Crates.io

About

This crate provides a very minimal set of utils to get started with writing Advent of Code solutions.

AocCommand

Description

This is a CLI command builder that provides an input source (either a file or STDIN). The suggested workflow is to create a Rust project with one binary per AOC solution.

Here is an example help printout generated from a program generated by AocCommand:

Example description

USAGE:
    prog [FILE]

FLAGS:
    -h, --help       Prints help information
    -V, --version    Prints version information

ARGS:
    <FILE>    Input file (defaults to STDIN if not provided)

Usage

Collect all lines from input:

use std::io::BufRead;
use aoc_utils::AocCommand;

let input = AocCommand::new("Example solution").parse_args().unwrap();
let lines: Vec<String> = input.lines().map(Result::unwrap).collect();

for line in lines {
    println!("{}", line);
}

Dependencies

~1MB
~15K SLoC