Skip to content

andreaswilli/aoc-cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

38 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Advent of Code CLI

A CLI to make solving Advent of Code puzzles more convenient.

Features

  • πŸ‘Ÿ 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.

Installation

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.

Project Structure

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).

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
    },
    {
      //...
    }
  ]
}

Usage

There are two main commands, run and watch.

Run

Run once and exit.

Single Day

Run day 01 of year 2024:

aoc run 2024/01

All Days of Year

Run all days of year 2024:

aoc run 2024

Watch

Watch re-runs a day every time one of the files in its folder changes.

Single Day

Watch day 01 of year 2024:

aoc watch 2024/01

All Days of Year

Watch all days of year 2024:

aoc watch 2024

About

πŸŽ„ CLI for Advent of Code

Resources

Stars

Watchers

Forks