Metadata-Version: 2.4
Name: python-aoc
Version: 0.1.1
Summary: A Python CLI and library for interacting with the Advent of Code API to fetch puzzles, download inputs, and submit answers.
Project-URL: Homepage, https://github.com/benjaminrall/python-aoc
Author-email: benjaminrall <benr2508@aol.com>
License: MIT License
        
        Copyright (c) 2025 Benjamin Rall
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Requires-Python: >=3.12
Requires-Dist: requests>=2.32.4
Requires-Dist: typer>=0.16.0
Description-Content-Type: text/markdown

# Python Advent of Code 🎄

A Python CLI and library for interacting with the [Advent of Code](https://adventofcode.com/) API.

## Key Features

- 🌐 Opens the daily puzzle page in your browser
- 🚀 Downloads your personalised puzzle inputs
- 📂 Generates new solution files from a template
- ✅ Tests and directly submits your solutions

## Installation

To use the project, you can simply install it using `pip`:

```sh
pip install python-aoc
```

It can then be used in the command line and imported as a library with `pyaoc`.

## Configuration

To interact with the Advent of Code API, you must provide your session token. This tool reads the token from an environment variable named `AOC_SESSION`, which can be set manually or through the following command:

```sh
pyaoc session set <your-session-token>
```

## Quick Start

The most common workflow is to create, test, and submit a solution.

1. **Create the files for a new day**:

   The following command will create a `day-5/` directory, download the input into `day-5/input.txt`, create a `day-5/test.txt` file to hold a test input, and create a `day-5/main.py` script file from the default `python-aoc` template:

   ```sh
   pyaoc create 5 2025
   ```

2. **Test your solution against a known answer**:

   Once you have completed your solution to the puzzle, written in a `solve` function which takes in the path to an input file, you can test it against a known answer for an example case in `test.txt`:

   ```sh
   # Assuming the example answer is 123
   pyaoc test day-5/main.py 123 --test-input-path day-5/test.txt
   ```

3. **Submit your final solution**:

   Then, the final solution for the specified part can be submitted using the `submit` command:

   ```sh
   pyaoc submit day-5/main.py 1 --day 5 --year 2025 --input-path day-5/input.txt
   ```

For the complete list of CLI commands and their arguments, run `pyaoc --help`.

## Library usage

You can also import and use the core functions in your own Python scripts:

```py
import pyaoc

# Sets the session token (if it's not already set as an environment variable)
pyaoc.set_session("your-session-token")

try:
    # Get puzzle input for Dec 1, 2023
    puzzle_input = pyaoc.get_day_input(day=1, year=2023)
    print(puzzle_input[:50]) # Print the first 50 characters
except Exception as e:
    print(f"An error occurred: {e}")
```

## License

This project is licensed under the **MIT License**. See the `LICENSE` file for details.
