From 920897cf2f7df1a467a5ea1cb9805f0e647306ce Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Mon, 6 Dec 2010 22:37:57 -0500 Subject: [PATCH] fixed usage of "when" sqlite keyword; made dbfile a required argument --- dwtt | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/dwtt b/dwtt index a68a163..0ae9867 100755 --- a/dwtt +++ b/dwtt @@ -10,32 +10,32 @@ from datetime import datetime PROGRAM_NAME = 'dwtt' def usage(): - print '''Usage: dwtt [options] + print '''Usage: dwtt [options] Options: -c Open a window to take a command as input - -d|--dbfile Use dbfile as the database file --help Show this help ''' def main(argv): try: - opts, args = getopt.getopt(argv[1:], "d:c", ["help", "dbfile="]) + opts, args = getopt.getopt(argv[1:], "c", ["help"]) except getopt.GetoptError: usage() sys.exit(1) - timedbfile = os.path.expanduser('~/.' + PROGRAM_NAME + '.db') timenow = datetime.now() for opt, arg in opts: - if opt in ("-d", "--dbfile"): - timedbfile = arg - elif opt == '-c': + if opt == '-c': cmd = doCmdWindow() print "cmd was:", cmd elif opt == "--help": usage() sys.exit() + if len(args) < 1: + usage() + sys.exit(2) + timedbfile = args[0] if not os.path.exists(timedbfile): createdb(timedbfile) @@ -52,7 +52,7 @@ CREATE TABLE tasks ( )''') c.execute(''' CREATE TABLE entries ( - when INTEGER PRIMARY KEY, + date INTEGER PRIMARY KEY, taskid INTEGER, hours REAL, FOREIGN KEY (taskid) REFERENCES tasks(id)