argparser: add argparser and nice print

This commit is contained in:
Marco Thomas
2022-07-28 11:10:37 +02:00
parent d29c08a411
commit 15b156a7c6
5 changed files with 94 additions and 35 deletions

30
args.py Normal file
View File

@@ -0,0 +1,30 @@
"""
Parse commandline arguments and provide global variables for settings.
"""
import argparse
class Settings():
file = None
sort = "time"
debug = False
def __init__(self):
parser = argparse.ArgumentParser(description='IHK Dijkstra Projekt.')
parser.add_argument('file', help='The input file.')
parser.add_argument(
'-sort',
default='time',
help='Whether to sort after "time" or "co2"')
parser.add_argument(
'-debug',
action='store_true',
help='Show debug output.')
args = parser.parse_args()
assert(args.sort == "time" or args.sort == "co2")
# update default values
self.file = args.file
self.debug = args.debug
self.sort = args.sort