#!/usr/bin/env python3
import ptime.client as client
from ptime.util import *
import sys


def summarize(data):
    sum_dict = task_summary(data["task_list"])
    start_time = data["start_time"]
    end_time = data["end_time"]
    print_summary(start_time, end_time, sum_dict)


data = client.run(sys.argv[1:])
for prefix,task_key in [("Completed task", "completed_task"),
                        ("Started task", "started_task"),
                        ("Active task", "active_task")]:
    if task_key in data:
        print(fmt_task(prefix, data[task_key]))

if sys.argv[1] == "sum":
    summarize(data)

if sys.argv[1] == "list":
    print(data)
