master > master: code - refactored
This commit is contained in:
41
code/setup/cli.py
Normal file
41
code/setup/cli.py
Normal file
@@ -0,0 +1,41 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
# IMPORTS
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
from code.local.typing import *;
|
||||
|
||||
from code.core.log import *;
|
||||
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
# GLOBAL VARIABLES
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
parser = None;
|
||||
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
# METHODS
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
def GetArgumentParser() -> argparse.ArgumentParser:
|
||||
global parser;
|
||||
if not isinstance(parser, argparse.ArgumentParser):
|
||||
parser = argparse.ArgumentParser(
|
||||
prog='code/main.py',
|
||||
description=dedent('''
|
||||
\033[93;1mBeschreibung:\033[0m
|
||||
\033[93;2mEin Programm, das verschiedene Algorithmen aus dem Kurs AlgoDat I testet.\033[0m
|
||||
'''),
|
||||
formatter_class=argparse.RawTextHelpFormatter,
|
||||
);
|
||||
parser.add_argument('mode', nargs=1, choices=['all'], help='all = Führt alle Testfälle in der config.yml Datei durch.');
|
||||
parser.add_argument('--path', nargs=1, type=str, help='Pfad zur alternativen Configdatei.');
|
||||
parser.add_argument('--debug', action='store_true', help='Debugging Messages stummschalten.')
|
||||
parser.add_argument('-q', '--quiet', action='store_true', help='Alle console-messages bis auf Errors stummschalten.')
|
||||
return parser;
|
||||
|
||||
def GetArgumentsFromCli(cli_args: List[str]) -> argparse.Namespace:
|
||||
parser = GetArgumentParser();
|
||||
return parser.parse_args(cli_args);
|
||||
Reference in New Issue
Block a user