Merge pull request #15 from hut/version_option

Version option
This commit is contained in:
Damien Elmes 2013-02-21 22:13:20 -08:00
commit 000efed5cd

View File

@ -163,7 +163,7 @@ class AnkiApp(QApplication):
def parseArgs(argv): def parseArgs(argv):
"Returns (opts, args)." "Returns (opts, args)."
parser = optparse.OptionParser() parser = optparse.OptionParser(version="%prog " + appVersion)
parser.usage = "%prog [OPTIONS] [file to import]" parser.usage = "%prog [OPTIONS] [file to import]"
parser.add_option("-b", "--base", help="path to base folder") parser.add_option("-b", "--base", help="path to base folder")
parser.add_option("-p", "--profile", help="profile name to load") parser.add_option("-p", "--profile", help="profile name to load")
@ -174,6 +174,11 @@ def run():
global mw global mw
from anki.utils import isMac from anki.utils import isMac
# parse args
opts, args = parseArgs(sys.argv)
opts.base = unicode(opts.base or "", sys.getfilesystemencoding())
opts.profile = unicode(opts.profile or "", sys.getfilesystemencoding())
# on osx we'll need to add the qt plugins to the search path # on osx we'll need to add the qt plugins to the search path
if isMac and getattr(sys, 'frozen', None): if isMac and getattr(sys, 'frozen', None):
rd = os.path.abspath(moduleDir + "/../../..") rd = os.path.abspath(moduleDir + "/../../..")
@ -203,11 +208,6 @@ environment points to a valid, writable folder.""")
"upgrade to a newer Qt, you may experience issues such as images " "upgrade to a newer Qt, you may experience issues such as images "
"failing to show up during review.") "failing to show up during review.")
# parse args
opts, args = parseArgs(sys.argv)
opts.base = unicode(opts.base or "", sys.getfilesystemencoding())
opts.profile = unicode(opts.profile or "", sys.getfilesystemencoding())
# profile manager # profile manager
from aqt.profiles import ProfileManager from aqt.profiles import ProfileManager
pm = ProfileManager(opts.base, opts.profile) pm = ProfileManager(opts.base, opts.profile)