mix aoc (Advent of Code Utilities v0.1.3) View Source

Fetch input and create a code skeleton for a given day / year.

This mix task:

  • Creates a code skeleton for the specified day / year
  • Fetches the input of day / year and stores it
  • Prints the url of today's challenge.

If this task is run multiple times for the same day / year, the input is not fetched again (if it has not been deleted) and existing files are not overwritten.

In order to fetch your input, this task needs your advent of code session cookie. This can be obtained by investigating your cookies after logging in on the advent of code website. The cookie can be stored inside your config/config.exs file (e.g. config, :advent_of_code_utils, :session, "<your cookie here>") or it can be passed as a command-line argument. If no cookie is present, the input can not be fetched.

Day and Year

The day and year can be passed as a command-line argument or be specified in the application configuration. If neither of these are present, today's date is used.

File locations

By default, this task stores the fetched inputs in input/<year>_<day>.txt. The code skeletons are stored in lib/<year>/<day>.ex. These values can be modified by setting the :input_path and :code_path values of the :advent_of_code_utils application. The provided path should be a string which may contain :year and :day. If these values are present, they will be replaced by the relevant day or year.

For instance, the following code will store inputs in inputs/<year>/<day>.input:

config :advent_of_code_utils, :input_path, "inputs/:year/:day.input"

Command-line arguments

  • -s or --session: Specify the session cookie.
  • -y or --year: Specify the year.
  • -d or --day: Specify the day.

All of these options take precedence over their application environment counterparts.

Link to this section Summary

Functions

Callback implementation for Mix.Task.run/1.

Link to this section Functions

Callback implementation for Mix.Task.run/1.