Add mode argument, default 'total'

This commit is contained in:
karl 2020-12-15 00:34:52 +01:00
parent 59722e19a2
commit 20a66b8f48

11
tx
View File

@ -8,6 +8,10 @@ parser = argparse.ArgumentParser(description="Description")
# add arguments to the parser
parser.add_argument("-f", "--file")
parser.add_argument("mode",
help="display the square of a given number",
nargs='?', default="total",
choices=["total"])
args = parser.parse_args()
@ -16,9 +20,10 @@ if args.file:
else:
time_file = open('time.txt','r')
total_time = timedelta()
if args.mode == "total":
total_time = timedelta()
for line in time_file:
for line in time_file:
date_time_description = line.split(" ", 2)
hours, minutes = date_time_description[1].split(':', 1)
@ -26,4 +31,4 @@ for line in time_file:
total_time += delta
print('Total time: ', total_time)
print('Total time: ', total_time)