From a5984f0965f12256754e39bda03db7d5e2555eca Mon Sep 17 00:00:00 2001 From: Kilian Krause Date: Wed, 5 Jul 2023 11:21:31 +0200 Subject: [PATCH] permit overriding config filename/path as argument --- src/capport/config.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/capport/config.py b/src/capport/config.py index 3317115..8311382 100644 --- a/src/capport/config.py +++ b/src/capport/config.py @@ -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)