remove -c option, made its behavior the default, fix DataStore bug

This commit is contained in:
Josh Holtrop 2010-12-28 19:02:28 -05:00
parent ec4383c993
commit be2789de8d
2 changed files with 11 additions and 8 deletions

View File

@ -6,7 +6,7 @@ class DataStore:
def __init__(self, timedbfile):
if not os.path.exists(timedbfile):
self.createdb(timedbfile)
self.conn = sqlite3.connect(dbfile)
self.conn = sqlite3.connect(timedbfile)
def __del__(self):
self.conn.close()

17
dwtt
View File

@ -5,19 +5,19 @@ from Command import Command
import sys
import getopt
from datetime import datetime
from DataStore import DataStore
PROGRAM_NAME = 'dwtt'
def usage():
print '''Usage: dwtt [options] <dbfile>
Options:
-c Open a window to take a command as input
--help Show this help
'''
def main(argv):
try:
opts, args = getopt.getopt(argv[1:], "c", ["help"])
opts, args = getopt.getopt(argv[1:], "", ["help"])
except getopt.GetoptError:
usage()
sys.exit(1)
@ -25,13 +25,13 @@ def main(argv):
timenow = datetime.now()
for opt, arg in opts:
if opt == '-c':
cmdline = doCmdWindow()
print "cmd was:", cmdline
cmd = Command(timenow, cmdline)
elif opt == "--help":
if opt == "--help":
usage()
sys.exit()
else:
usage()
sys.exit(3)
if len(args) < 1:
usage()
sys.exit(2)
@ -39,6 +39,9 @@ def main(argv):
ds = DataStore(timedbfile)
cmdline = doCmdWindow()
cmd = Command(timenow, cmdline)
def doCmdWindow():
c = CmdWindow()
return c.main()