argparser: add argparser and nice print
This commit is contained in:
30
args.py
Normal file
30
args.py
Normal 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
|
||||
Reference in New Issue
Block a user