Allow overriding individual configuration options on the command line
This commit is contained in:
parent
e012e9459d
commit
cbe599735c
@ -242,7 +242,7 @@ def merge_configs(ans, vals):
|
||||
return ans
|
||||
|
||||
|
||||
def load_config(*paths) -> Options:
|
||||
def load_config(*paths, overrides=None) -> Options:
|
||||
ans = defaults._asdict()
|
||||
for path in paths:
|
||||
if not path:
|
||||
@ -254,6 +254,9 @@ def load_config(*paths) -> Options:
|
||||
with f:
|
||||
vals = parse_config(f)
|
||||
ans = merge_configs(ans, vals)
|
||||
if overrides is not None:
|
||||
vals = parse_config(overrides)
|
||||
ans = merge_configs(ans, vals)
|
||||
return Options(**ans)
|
||||
|
||||
|
||||
|
||||
@ -54,6 +54,15 @@ def option_parser():
|
||||
' config files in sequence, which are merged. Default: {}'
|
||||
).format(defconf)
|
||||
)
|
||||
a(
|
||||
'--override',
|
||||
'-o',
|
||||
action='append',
|
||||
help=_(
|
||||
'Override individual configuration options, can be specified'
|
||||
' multiple times. Syntax: name=value. For example: {}'
|
||||
).format('-o font_size=20')
|
||||
)
|
||||
a(
|
||||
'--cmd',
|
||||
'-c',
|
||||
@ -213,7 +222,8 @@ def main():
|
||||
main(args.replay_commands)
|
||||
return
|
||||
config = args.config or (defconf, )
|
||||
opts = load_config(*config)
|
||||
overrides = (a.replace('=', ' ', 1) for a in args.override)
|
||||
opts = load_config(*config, overrides=overrides)
|
||||
change_wcwidth(not opts.use_system_wcwidth)
|
||||
glfw_set_error_callback(on_glfw_error)
|
||||
enable_automatic_opengl_error_checking(False)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user