Files
LibrarySystem/src/__init__.py
WorldTeacher 2836be7490 add updates
2024-10-02 15:28:12 +02:00

53 lines
1.4 KiB
Python

import sys
from config import Config#
__version__ = "0.1.0"
__author__ = "Alexander Kirchner"
__email__ = "alexander.kirchner@ph-freiburg.de"
__license__ = "MIT"
config = Config("config/settings.yaml")
valid_args = ["--debug", "--log", "--no-backup", "--ic-logging", "--version", "-h"]
args_description = {
"--debug": "Enable debug mode",
"--log": "Enable logging",
"--no-backup": "Disable database backup",
"--ic-logging": "Enable icecream logging (not available in production)",
"--version": "Show version",
"-h": "Show help message and exit"
}
args = sys.argv[1:]
if any(arg not in valid_args for arg in args):
print("Invalid argument present")
#sys.exit()
def help():
print("Ausleihsystem")
print("Ein Ausleihsystem für Handbibliotheken")
print("Version: {}".format(__version__))
print("Valide Argumente:")
print("args")
print("--------")
print("usage: main.py [-h] [--debug] [--log] [--no-backup] [--ic-logging] [--version]")
print("options:")
for arg in valid_args:
print(f"{arg} : {args_description[arg]}")
# based on the arguments, set the config values
if"-h" in args:
help()
sys.exit()
if "--debug" in args:
config.debug = True
if "--log" in args:
config.log_debug = True
if "--no-backup" in args:
config.no_backup = True
if "--ic-logging" in args:
config.ic_logging = True
if "--version" in args:
print(__version__)
sys.exit()