#!/usr/bin/env python

import argparse
from stamper import Stamper


if __name__ == '__main__':

    parser = argparse.ArgumentParser(
        description='stamps: show recorded times information')
    parser.add_argument('customer', action="store", nargs='?',
                        help='Show times only for this customer')
    parser.add_argument('filter', action="store", nargs='?',
                        help='Filter the times by date range')
    parser.add_argument('-v', '--verbose', action="store_true",
                        help='Include detailed times information')
    parser.add_argument('-s', '--sum', action="store_true",
                        help='Include sum of times')
    parser.add_argument('-g', '--graph', action="store_true",
                        help='Generate a SVG graph')
    parser.add_argument('-t', '--timeline', action="store_true",
                        help='Show a timeline of recorded times')

    args = parser.parse_args()

    s = Stamper()
    s.load_stamps()

    # Set proper arguments if they have passed a date-based filter without
    # a customer
    if args.customer not in s.customers and not args.filter:
        args.filter = args.customer
        args.customer = None

    # Call the proper methods, based on the given parameters
    if args.timeline:
        s.timeline()
    else:
        s.show_stamps(args.customer, args.filter, args.verbose, args.sum,
                      args.graph)
