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): def __init__(self, timedbfile):
if not os.path.exists(timedbfile): if not os.path.exists(timedbfile):
self.createdb(timedbfile) self.createdb(timedbfile)
self.conn = sqlite3.connect(dbfile) self.conn = sqlite3.connect(timedbfile)
def __del__(self): def __del__(self):
self.conn.close() self.conn.close()

17
dwtt
View File

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