libaoc
Advent of Code CLI and utilities.
CLI
Handle puzzle retrieval, viewing and submission from the command line.
Get
the puzzle's questions and input. The contents are cached after every request / submission.Submit
the answer in a couple of key presses.View
the puzzle from the terminal or editor in markdown format.
[!WARNING] An
AOC_AUTH_TOKEN
environment variable is required for user validation. See here.
Install
Example
Retrieve the puzzle's questions and answers for a certain day and year.
Submit an answer for a specific puzzle and part.
If the day or year is omitted, it will be derived from the current directory's structure. If the puzzle's part is omitted, it will smartly be chosen from the puzzle state. Almost all commands can be shortened in this way.
Take a look at the help.
)
API
A Rust client for the Advent of Code API.
Install
Example
Use the client to scrape a puzzle from the website. The session token is required to verify the user.
use :Client;
let token = "53616c...";
let client = new?;
let puzzle = client.scrape_puzzle?;
Get a puzzle from the cache or by scraping the website if the puzzle is not present.
let id = ;
let puzzle = client.get_puzzle?;
prinln!;
prinln!;
write;
Submit an answer. When using the CLI the id
and part
can be automatically
determined if omitted.
let id = ;
let part = 2;
client.submit?;
Refresh the in cache puzzle by re-scraping the website. This is done after a successful submission of part one to retrieve part two automatically.
let puzzle = client.refresh_puzzle?;
Session token
To correctly set your AOC_AUTH_TOKEN
environment variable, find the cookie
field in the request headers used when requesting a page, https://adventofcode.com/2015/day/1
for example, you can do so by opening the network panel
in your browser and
check for the field cookie
in the request headers of the current page. You
can also right click on the request and copy the cURL command used.
Remember that you must be logged in
for your session cookie to be present in your request headers.