dwtt/dwtt
2011-01-01 23:14:12 -05:00

57 lines
1.1 KiB
Python
Executable File

#!/usr/bin/env python
import os
import sys
import getopt
from CmdWindow import CmdWindow
from Command import Command
from DataStore import DataStore
PROGRAM_NAME = 'dwtt'
def usage():
print '''Usage: dwtt [options] [dbfile]
Options:
--help Show this help
'''
def main(argv):
try:
opts, args = getopt.getopt(argv[1:], "", ["help"])
except getopt.GetoptError:
usage()
sys.exit(1)
for opt, arg in opts:
if opt == "--help":
usage()
sys.exit()
else:
usage()
sys.exit(3)
timedbfile = os.path.expanduser('~') + os.path.sep + '.dwtt.db'
if len(args) >= 1:
timedbfile = args[0]
ds = DataStore(timedbfile)
while True:
cmdline = doCmdWindow()
cmd = Command(cmdline)
if not processCommand(cmd, ds):
break
def doCmdWindow():
c = CmdWindow()
return c.main()
# Returns boolean for whether the command prompt should be displayed again
def processCommand(cmd, store):
print cmd
return cmd.command == 'status'
if __name__ == "__main__":
main(sys.argv)