62 lines
1.7 KiB
Python
62 lines
1.7 KiB
Python
import sys
|
|
from config import Config
|
|
__version__ = "0.1.0"
|
|
__author__ = "Alexander Kirchner"
|
|
__email__ = "alexander.kirchner@ph-freiburg.de"
|
|
__license__ = "MIT"
|
|
docport = 6543
|
|
|
|
|
|
config = Config("config/settings.yaml")
|
|
valid_args = ["--debug", "--log", "--no-backup", "--ic-logging", "--version", "-h","--no-documentation"]
|
|
|
|
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",
|
|
"--no-documentation": "Disable documentation server and shortcut"
|
|
}
|
|
|
|
args = sys.argv[1:]
|
|
if any(arg not in valid_args for arg in args):
|
|
print("Invalid argument present")
|
|
print([arg for arg in args if arg not in valid_args])
|
|
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] [--no-documentation]")
|
|
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 "--no-documentation" in args:
|
|
config.documentation = False
|
|
if "--version" in args:
|
|
print(__version__)
|
|
sys.exit()
|
|
|
|
|
|
|
|
|