2
0

permit overriding config filename/path as argument

This commit is contained in:
Kilian Krause 2023-07-05 11:21:31 +02:00
parent 1acb693e2b
commit a5984f0965

View File

@ -2,6 +2,7 @@ from __future__ import annotations
import dataclasses
import os.path
import sys
import typing
import yaml
@ -30,6 +31,10 @@ class Config:
@staticmethod
def load(filename: typing.Optional[str] = None) -> Config:
if filename is None:
if len(sys.argv) > 0:
for name in sys.argv[1:]:
if os.path.exists(name):
return Config.load(name)
for name in ('capport.yaml', '/etc/capport.yaml'):
if os.path.exists(name):
return Config.load(name)