master > master: code - argparsing repariert
This commit is contained in:
parent
f4b2ca6c90
commit
3941348420
21
code/main.py
21
code/main.py
@ -26,11 +26,11 @@ PATH_TO_CONFIG: str = 'code/config.yml';
|
|||||||
# MAIN PROCESS
|
# MAIN PROCESS
|
||||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
def enter(quiet: bool, debug: bool, mode_all: Any, path: Any, **_):
|
def enter(quiet: bool, debug: bool, mode: str, path: Any, **_):
|
||||||
SetQuietMode(quiet);
|
SetQuietMode(quiet);
|
||||||
SetDebugMode(debug);
|
SetDebugMode(debug);
|
||||||
configpath = path if isinstance(path, str) else PATH_TO_CONFIG;
|
configpath = path if isinstance(path, str) else PATH_TO_CONFIG;
|
||||||
if mode_all is not None:
|
if mode == 'all':
|
||||||
LoopThroughCases(path=configpath);
|
LoopThroughCases(path=configpath);
|
||||||
else:
|
else:
|
||||||
parser.print_help();
|
parser.print_help();
|
||||||
@ -77,14 +77,19 @@ if __name__ == '__main__':
|
|||||||
cli_args = sys.argv[1:];
|
cli_args = sys.argv[1:];
|
||||||
parser = argparse.ArgumentParser(
|
parser = argparse.ArgumentParser(
|
||||||
prog='code/main.py',
|
prog='code/main.py',
|
||||||
description='''
|
description=dedent('''
|
||||||
\033[2;1mBeschreibung:\033[0m
|
\033[93;1mBeschreibung:\033[0m
|
||||||
\033[2mEin Programm, das verschiedene Algorithmen aus dem Kurs AlgoDat I testet.\033[0m
|
\033[93;2mEin Programm, das verschiedene Algorithmen aus dem Kurs AlgoDat I testet.\033[0m
|
||||||
''',
|
'''),
|
||||||
|
formatter_class=argparse.RawTextHelpFormatter,
|
||||||
);
|
);
|
||||||
parser.add_argument('all', nargs='?', help='Führt alle Testfälle in der config.yml Datei durch.');
|
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('--path', nargs=1, type=str, help='Pfad zur alternativen Configdatei.');
|
||||||
parser.add_argument('--debug', action='store_true', help='Debugging Messages stummschalten.')
|
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.')
|
parser.add_argument('-q', '--quiet', action='store_true', help='Alle console-messages bis auf Errors stummschalten.')
|
||||||
|
try:
|
||||||
args = parser.parse_args(cli_args);
|
args = parser.parse_args(cli_args);
|
||||||
enter(quiet=args.quiet, debug=args.debug, mode_all=args.all, path=args.path);
|
except:
|
||||||
|
parser.print_help();
|
||||||
|
exit(1);
|
||||||
|
enter(quiet=args.quiet, debug=args.debug, mode=args.mode[0], path=args.path);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user