solo-auswertung/src/solo_turnier/cli.py

89 lines
2.2 KiB
Python

import argparse
import logging
import debugpy
class Cli:
def __init__(self, l: logging.Logger):
parser = argparse.ArgumentParser()
# parser.add_argument('--gui', help='Show the GUI', action='store_true')
parser.add_argument(
"--no-flask",
action="store_false",
dest="flask",
help="Disable the internal flask web server",
)
parser.add_argument(
"--port", help="The port to listen for incoming requests", default="8082"
)
parser.add_argument(
"html",
help="The path from where to look for HTML export files",
nargs=1,
default=["."],
)
parser.add_argument(
"-o",
"--output",
help="Set the output path of the script",
nargs=1,
default=[None],
)
parser.add_argument(
"--all-participants",
"-a",
action="store_true",
help="Show all participants not only finalists",
)
parser.add_argument(
"-v", "--verbose", help="Increase verbosity", action="count", default=0
)
parser.add_argument(
"-d",
"--debug",
action="store_true",
help="Activate debugging during startup",
)
self.__args = parser.parse_args()
if self.__args.debug:
debugpy.listen(5678)
debugpy.wait_for_client()
self.externalDebugger = self.__args.debug
map = {
0: logging.ERROR,
1: logging.WARN,
2: logging.INFO,
3: logging.DEBUG,
4: 5,
}
logLevel = map.get(self.__args.verbose, logging.DEBUG)
l.setLevel(logLevel)
def showGUI(self):
# return self.__args.gui
return False
def startFlaskServer(self):
return self.__args.flask
def importHtmlPath(self):
return self.__args.html[0]
def output(self):
return self.__args.output[0]
def getLogLevel(self):
return self.__args.verbose
def showAllParticipants(self):
return self.__args.all_participants
def getPort(self):
return int(self.__args.port)