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
|
return ans
|
||||||
|
|
||||||
|
|
||||||
def load_config(*paths) -> Options:
|
def load_config(*paths, overrides=None) -> Options:
|
||||||
ans = defaults._asdict()
|
ans = defaults._asdict()
|
||||||
for path in paths:
|
for path in paths:
|
||||||
if not path:
|
if not path:
|
||||||
@ -254,6 +254,9 @@ def load_config(*paths) -> Options:
|
|||||||
with f:
|
with f:
|
||||||
vals = parse_config(f)
|
vals = parse_config(f)
|
||||||
ans = merge_configs(ans, vals)
|
ans = merge_configs(ans, vals)
|
||||||
|
if overrides is not None:
|
||||||
|
vals = parse_config(overrides)
|
||||||
|
ans = merge_configs(ans, vals)
|
||||||
return Options(**ans)
|
return Options(**ans)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -54,6 +54,15 @@ def option_parser():
|
|||||||
' config files in sequence, which are merged. Default: {}'
|
' config files in sequence, which are merged. Default: {}'
|
||||||
).format(defconf)
|
).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(
|
a(
|
||||||
'--cmd',
|
'--cmd',
|
||||||
'-c',
|
'-c',
|
||||||
@ -213,7 +222,8 @@ def main():
|
|||||||
main(args.replay_commands)
|
main(args.replay_commands)
|
||||||
return
|
return
|
||||||
config = args.config or (defconf, )
|
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)
|
change_wcwidth(not opts.use_system_wcwidth)
|
||||||
glfw_set_error_callback(on_glfw_error)
|
glfw_set_error_callback(on_glfw_error)
|
||||||
enable_automatic_opengl_error_checking(False)
|
enable_automatic_opengl_error_checking(False)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user