fixed usage of "when" sqlite keyword; made dbfile a required argument

This commit is contained in:
Josh Holtrop 2010-12-06 22:37:57 -05:00
parent 9a70a7e9f8
commit 920897cf2f

16
dwtt
View File

@ -10,32 +10,32 @@ from datetime import datetime
PROGRAM_NAME = 'dwtt'
def usage():
print '''Usage: dwtt [options]
print '''Usage: dwtt [options] <dbfile>
Options:
-c Open a window to take a command as input
-d|--dbfile <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)