Now support multiple -k options on the command line.
Patch by Vladimir Marek fixes #113
This commit is contained in:
parent
6fbb23a8c5
commit
9c6581eb39
@ -50,12 +50,16 @@ def lock(config, ui):
|
|||||||
def startup(versionno):
|
def startup(versionno):
|
||||||
assert versionno == version.versionstr, "Revision of main program (%s) does not match that of library (%s). Please double-check your PYTHONPATH and installation locations." % (versionno, version.versionstr)
|
assert versionno == version.versionstr, "Revision of main program (%s) does not match that of library (%s). Please double-check your PYTHONPATH and installation locations." % (versionno, version.versionstr)
|
||||||
options = {}
|
options = {}
|
||||||
|
options['-k'] = []
|
||||||
if '--help' in sys.argv[1:]:
|
if '--help' in sys.argv[1:]:
|
||||||
sys.stdout.write(version.getcmdhelp() + "\n")
|
sys.stdout.write(version.getcmdhelp() + "\n")
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
for optlist in getopt(sys.argv[1:], 'P:1oqa:c:d:l:u:hk:f:')[0]:
|
for optlist in getopt(sys.argv[1:], 'P:1oqa:c:d:l:u:hk:f:')[0]:
|
||||||
options[optlist[0]] = optlist[1]
|
if optlist[0] == '-k':
|
||||||
|
options[optlist[0]].append(optlist[1])
|
||||||
|
else:
|
||||||
|
options[optlist[0]] = optlist[1]
|
||||||
|
|
||||||
if options.has_key('-h'):
|
if options.has_key('-h'):
|
||||||
sys.stdout.write(version.getcmdhelp())
|
sys.stdout.write(version.getcmdhelp())
|
||||||
@ -81,15 +85,14 @@ def startup(versionno):
|
|||||||
config.read(configfilename)
|
config.read(configfilename)
|
||||||
|
|
||||||
# override config values with option '-k'
|
# override config values with option '-k'
|
||||||
for option in options.keys():
|
for option in options['-k']:
|
||||||
if option == '-k':
|
(key, value) = option.split('=', 1)
|
||||||
(key, value) = options['-k'].split('=', 1)
|
if ':' in key:
|
||||||
if ':' in key:
|
(secname, key) = key.split(':', 1)
|
||||||
(secname, key) = key.split(':', 1)
|
section = secname.replace("_", " ")
|
||||||
section = secname.replace("_", " ")
|
else:
|
||||||
else:
|
section = "general"
|
||||||
section = "general"
|
config.set(section, key, value)
|
||||||
config.set(section, key, value)
|
|
||||||
|
|
||||||
ui = offlineimap.ui.detector.findUI(config, options.get('-u'))
|
ui = offlineimap.ui.detector.findUI(config, options.get('-u'))
|
||||||
UIBase.setglobalui(ui)
|
UIBase.setglobalui(ui)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user