#!/usr/bin/env python

import chronologicon, argparse, chronologicon.output

# Set up argparse to get the arguments passed to Chron
parser = argparse.ArgumentParser(description="A minimal time tracker.", prog="chron")
parser.add_argument("-s", "--start", nargs="*", help="Start a new log.")
parser.add_argument("-x", "--stop", action="store_true", help="Complete the current log.")
parser.add_argument("--cancel", action="store_true", help="Cancel the current log.")
parser.add_argument("-b", "--backup", action="store_true", help="Back up the log file.")
parser.add_argument("-d", "--directory", nargs=1, help="Set a specified directory as the save folder.")
parser.add_argument("-v", "--view", nargs="*", help="View graphs for the current logs.")
args = parser.parse_args()

chronologicon.Preflights(args.directory)

if args.stop:
	chronologicon.StopLog()

if args.start is not None:
	chronologicon.StartLog(args.start)

if args.cancel:
	chronologicon.CancelLog()

if args.backup:
	chronologicon.Backup()

if args.view is not None:
	chronologicon.output.ViewStats(args.view)