A CLI to make solving Advent of Code puzzles more convenient.
- π Run multiple days with a single command - even if they are implemented in different languages.
- π Watch the filesystem and re-run whenever changes are detected.
- β Verify results against the content of a file so you immediately know if a refactoring broke something.
Clone this repo and run cd cmd/aoc && go install
from its root. This will
make the aoc
command available in your path.
Note
Go needs to be installed on your system for this to work.
Your project should be structured something like this:
advent-of-code/
ββ 2024/
β ββ 01/
β β ββ expected.txt
β β ββ solution.js
β ββ 02/
β β ββ expected.txt
β β ββ solution.py
β ββ ...
ββ lib/
β ββ node/
β ββ ...
ββ aoc-cli.json
Year and day folders can be named differently, it just needs to match the commands you run (see Usage).
The names of the files containing the source code need to be configured (see Config File).
The file expected.txt
can be omitted if the output should not be checked.
Otherwise it should contain the expected output written to stdout by your code.
The lib
directory is just an example, any additional paths can be configured
to be watched (see Config File).
The config file aoc-cli.json
has to be placed in the root of your project. It
defines engines to run your code. Find some examples here.
{
"engines": [
{
"name": "node", // engine name, for display only
"cmd": "node {{entryFile}}", // command to run, use file name placeholder
"entryFile": "solution.js", // file name of the source file
"extraFiles": ["lib/node"] // additional paths that should be watched
},
{
//...
}
]
}
There are two main commands, run
and watch
.
Run once and exit.
Run day 01
of year 2024
:
aoc run 2024/01
Run all days of year 2024
:
aoc run 2024
Watch re-runs a day every time one of the files in its folder changes.
Watch day 01
of year 2024
:
aoc watch 2024/01
Watch all days of year 2024
:
aoc watch 2024