Take config file as command line argument

This commit is contained in:
Adam Goldsmith 2022-03-29 15:11:01 -04:00
parent 4d5268cac1
commit 3c1afc7b73

View File

@ -1,6 +1,8 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import argparse
from datetime import datetime, timedelta from datetime import datetime, timedelta
import pathlib
from octorest import OctoRest from octorest import OctoRest
from ruamel.yaml import YAML from ruamel.yaml import YAML
@ -37,10 +39,19 @@ def get_printer_job(calendar, printer):
def main(): def main():
parser = argparse.ArgumentParser(description="Process some integers.")
parser.add_argument(
"--config",
type=pathlib.Path,
default="printers.yaml",
help="A yaml file defining printers to query (default: %(default)s)",
)
args = parser.parse_args()
calendar = CalendarService() calendar = CalendarService()
yaml = YAML(typ="safe") yaml = YAML(typ="safe")
with open("printers.yaml") as f: with open(args.config) as f:
printers = yaml.load(f) printers = yaml.load(f)
for printer in printers: for printer in printers: