Files
tt/main.py

42 lines
1.2 KiB
Python
Executable File

#!/usr/bin/python3
from util.str_to_datetime import str_to_datetime as datetime
from model.TimeSlotContainer import time_slot_container as tsc
from model.TimeSlot import TimeSlot
from util.views import convert_to_table
from util.parser import create_parser
if __name__ == "__main__":
parser = create_parser()
args = parser.parse_args()
if args.command == "ls":
print(convert_to_table(tsc.get_time_slots_by_date()))
elif args.command == "start":
if args.start is not None:
tsc.open_time_slot(args.name, datetime(args.start))
else:
tsc.open_time_slot(args.name)
print(f"Started event {args.name}.")
elif args.command == "end":
if args.end is not None:
tsc.close_time_slot(datetime(args.end))
else:
tsc.close_time_slot()
print("Ended event.")
elif args.command == "ps":
print(convert_to_table(tsc.get_open_time_slots()))
elif args.command == "add":
tsc.add_time_slot(args.name, datetime(args.start), datetime(args.end))
elif args.command == "acc":
d = tsc.accumulate_duration(args.query)
print(f"{d.seconds // 3600}:{d.seconds % 3600 // 60}")