Templates experimental
You can easily make language templates in your repository by:
- Create a folder named
templates
in your repository root. - Create the folder with the name of the language you want to add, this will be the name of the template.
- Add your files ending in
.tmpl
to the template folder. - Specify the runner command in the
runner
file.
For example, if you want to add a template for Rust, you can create a folder named templates/rust
and add your files ending in .tmpl
to it.
sh
rust
├── Cargo.toml
├── runner
└── src
└── main.rs
Then, you can use the template by running aoc start <day> -t <template_name>
where --template
(alias: -t
) is the name of the template you want to use.
Variables
You can use the following variables in your template files:
day
: The day number.year
: The year number.
Example:
rust
//! Day {day} Solution
//!
//! Solution to AoC {year} Day {day}
//! https://adventofcode.com/{year}/day/{day}
fn main() {
// let input = include_str!("../input.txt");
// println!("{input}");
}
This will be replaced with:
rust
//! Day 1 Solution
//!
//! Solution to AoC 2023 Day 1
//! https://adventofcode.com/2023/day/1
fn main() {
// let input = include_str!("../input.txt");
// println!("{input}");
}
WARNING
The {input}
formatting above may also be replaced, with just input
without the curly braces. This will be fixed in the future.