wip
This commit is contained in:
50
main.py
Normal file
50
main.py
Normal file
@@ -0,0 +1,50 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import pathlib
|
||||
from aoc import cli, input_file, run, exceptions
|
||||
import sys
|
||||
import os
|
||||
import dotenv
|
||||
|
||||
|
||||
SOLUTION_BASE = pathlib.Path("./src/solution")
|
||||
INPUT_BASE = pathlib.Path("./data/input")
|
||||
EXAMPLE_BASE = pathlib.Path("./data/example")
|
||||
|
||||
|
||||
def main() -> None:
|
||||
args = cli.argument_parser().parse_args()
|
||||
|
||||
session_token = os.getenv("AOC_SESSION_TOKEN")
|
||||
|
||||
try:
|
||||
match args.command:
|
||||
case "solve":
|
||||
input_data = input_file.get(
|
||||
args.year,
|
||||
args.day,
|
||||
session_token,
|
||||
EXAMPLE_BASE if args.example else INPUT_BASE,
|
||||
)
|
||||
run.run_day(args.year, args.day, input_data, SOLUTION_BASE)
|
||||
case "create":
|
||||
input_file.create(
|
||||
args.year,
|
||||
args.day,
|
||||
SOLUTION_BASE,
|
||||
INPUT_BASE,
|
||||
EXAMPLE_BASE,
|
||||
)
|
||||
case "download":
|
||||
input_file.create_input_file(
|
||||
args.year, args.day, session_token, INPUT_BASE, args.force
|
||||
)
|
||||
|
||||
except exceptions.AocError as e:
|
||||
print(f"error: {e}", file=sys.stderr)
|
||||
exit(1)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
dotenv.load_dotenv()
|
||||
main()
|
||||
Reference in New Issue
Block a user