mirror of
https://seed.flo-the.dev/z3gWc1qgaeZaoGwL4WTstLNoqjayM.git
synced 2025-12-06 04:47:35 +01:00
add CLI test
Signed-off-by: Florian Brandes <florian.brandes@posteo.de>
This commit is contained in:
@@ -400,11 +400,16 @@ class SMTPServer(Controller):
|
||||
return True
|
||||
|
||||
|
||||
def main() -> int:
|
||||
"""Main routine
|
||||
def parse_args(args=None) -> argparse.ArgumentParser.parse_args:
|
||||
"""Parse arguments
|
||||
|
||||
Returns:
|
||||
int: exit code
|
||||
Parameters
|
||||
----------
|
||||
args : List of strings
|
||||
|
||||
Returns
|
||||
-------
|
||||
argparse.ArgumentParser.parse_args : Namespace of arguments
|
||||
"""
|
||||
parser = argparse.ArgumentParser(
|
||||
description=__doc__.strip(),
|
||||
@@ -417,9 +422,21 @@ def main() -> int:
|
||||
default="./config.ini",
|
||||
help="configuration file",
|
||||
)
|
||||
args = parser.parse_args()
|
||||
setlocale(LC_ALL, "C") # for strftime
|
||||
return parser.parse_args(args)
|
||||
|
||||
|
||||
def main(args=None) -> int:
|
||||
"""Main routine
|
||||
|
||||
Returns:
|
||||
int: exit code
|
||||
"""
|
||||
args = parse_args(args)
|
||||
setlocale(LC_ALL, "C") # for strftime
|
||||
if len(args.config) == 0:
|
||||
raise OSError("No config file supplied")
|
||||
if not Path(args.config).is_file():
|
||||
raise OSError("Config file not found: " + str(args.config))
|
||||
try:
|
||||
config: Config = Config.from_ini(args.config)
|
||||
except RuntimeError as e:
|
||||
|
||||
Reference in New Issue
Block a user