argparse working
This commit is contained in:
parent
89a3c08a50
commit
3492294335
5 changed files with 1057 additions and 0 deletions
0
adventofcode/__init__.py
Normal file
0
adventofcode/__init__.py
Normal file
10
adventofcode/lib.py
Executable file
10
adventofcode/lib.py
Executable file
|
@ -0,0 +1,10 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
# This function will read a file path and return a data object.
|
||||
# It does no other data manimpulation.
|
||||
def read_file(file_path):
|
||||
# Open a file in read mode
|
||||
with open(file_path, "r") as file:
|
||||
data = file.read()
|
||||
print(data)
|
||||
return data
|
33
aoc.py
Executable file
33
aoc.py
Executable file
|
@ -0,0 +1,33 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import argparse
|
||||
|
||||
|
||||
def argparser(*args, **kwargs):
|
||||
parser = argparse.ArgumentParser(
|
||||
prog="python aoc.py",
|
||||
description="Streamlined Advent of Code",
|
||||
epilog="We have to save christmas!",
|
||||
argument_default=None,
|
||||
)
|
||||
parser.add_argument(
|
||||
"-y",
|
||||
"--years",
|
||||
nargs="1",
|
||||
dest="years",
|
||||
default="2024",
|
||||
help="set what years to solve problems from",
|
||||
)
|
||||
parser.add_argument(
|
||||
"-d",
|
||||
"--days",
|
||||
nargs="1",
|
||||
dest="days",
|
||||
default="1",
|
||||
help="set what days to solve",
|
||||
)
|
||||
return parser.parse_args()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
args = argparser()
|
1000
data/2024/day01a.txt
Normal file
1000
data/2024/day01a.txt
Normal file
File diff suppressed because it is too large
Load diff
14
solutions/2024/day01.py
Executable file
14
solutions/2024/day01.py
Executable file
|
@ -0,0 +1,14 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
from aoc.common.lib import read_file
|
||||
|
||||
|
||||
def main():
|
||||
input_file = "../../data/24/01a.txt"
|
||||
data = read_file(input_file)
|
||||
print(data)
|
||||
return
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
Loading…
Add table
Add a link
Reference in a new issue