diff --git a/dwtt b/dwtt new file mode 100755 index 0000000..e3ae7cc --- /dev/null +++ b/dwtt @@ -0,0 +1,49 @@ +#!/usr/bin/env python + +import gtk +import sqlite3 +import os +import sys +import getopt +from datetime import datetime + +PROGRAM_NAME = 'dwtt' + +def usage(): + 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="]) + except getopt.GetoptError: + usage() + sys.exit(1) + + timedbfile = os.path.expanduser('~/.' + PROGRAM_NAME + '.db') + + for opt, arg in opts: + if opt in ("-d", "--dbfile"): + timedbfile = arg + elif opt == "--help": + usage() + sys.exit() + + if not os.path.exists(timedbfile): + createdb(timedbfile) + +def createdb(dbfile): + conn = sqlite3.connect(dbfile) + c = conn.cursor() + c.execute('''CREATE TABLE projects (name TEXT UNIQUE)''') + c.execute('''CREATE TABLE aliases (name TEXT UNIQUE, project TEXT)''') + conn.commit() + c.close() + conn.close() + +if __name__ == "__main__": + main(sys.argv)