take dbfile as an argument, default to ~/.dwtt.db
This commit is contained in:
parent
d316405db7
commit
cd1fbf332c
21
dwtt
21
dwtt
@ -5,21 +5,23 @@ import sys
|
||||
import getopt
|
||||
|
||||
from Window import *
|
||||
from DataStore import *
|
||||
|
||||
PROGRAM_NAME = 'dwtt'
|
||||
|
||||
def usage():
|
||||
print '''Usage: dwtt [options] [dbfile]
|
||||
print '''Usage: %s [options] [dbfile]
|
||||
Options:
|
||||
--help Show this help
|
||||
'''
|
||||
''' % PROGRAM_NAME
|
||||
|
||||
def main(argv):
|
||||
dbfile = os.path.expanduser('~/.%s.db' % PROGRAM_NAME)
|
||||
try:
|
||||
opts, args = getopt.getopt(argv[1:], "", ["help"])
|
||||
except getopt.GetoptError:
|
||||
usage()
|
||||
sys.exit(1)
|
||||
return 2
|
||||
|
||||
for opt, arg in opts:
|
||||
if opt == "--help":
|
||||
@ -27,10 +29,17 @@ def main(argv):
|
||||
sys.exit()
|
||||
else:
|
||||
usage()
|
||||
sys.exit(3)
|
||||
return 2
|
||||
|
||||
w = Window()
|
||||
if len(args) == 1:
|
||||
dbfile = args[0]
|
||||
elif len(args) > 1:
|
||||
usage()
|
||||
return 2
|
||||
|
||||
ds = DataStore(dbfile)
|
||||
w = Window(ds)
|
||||
w.main()
|
||||
|
||||
if __name__ == "__main__":
|
||||
main(sys.argv)
|
||||
sys.exit(main(sys.argv))
|
||||
|
Loading…
x
Reference in New Issue
Block a user