Rev3746, Fix open_browser parsing with non-main cli command

This commit is contained in:
shortcutme 2019-01-02 02:31:04 +01:00
parent 83ed87cec0
commit 859c81c81b
No known key found for this signature in database
GPG key ID: 5B63BAE6CB9613AE

View file

@ -13,7 +13,7 @@ class Config(object):
def __init__(self, argv):
self.version = "0.6.4"
self.rev = 3745
self.rev = 3746
self.argv = argv
self.action = None
self.pending_changes = {}
@ -400,15 +400,16 @@ class Config(object):
if section != "global": # If not global prefix key with section
key = section + "_" + key
to_end = key == "open_browser" # Prefer config value over argument
if key == "open_browser": # Prefer config file value over cli argument
if "--%s" % key in argv:
pos = argv.index("--open_browser")
del argv[pos:pos + 2]
argv_extend = ["--%s" % key]
if val:
for line in val.strip().split("\n"): # Allow multi-line values
argv_extend.append(line)
if to_end:
argv = argv[:-2] + argv_extend + argv[-2:]
else:
argv = argv[:1] + argv_extend + argv[1:]
return argv