mirror of
https://github.com/glomatico/gamdl.git
synced 2026-06-13 12:15:18 +03:00
Remove unknown params from config file
This commit is contained in:
@@ -92,6 +92,21 @@ class ConfigFile:
|
||||
if has_changes:
|
||||
self._write_config_file()
|
||||
|
||||
def cleanup_unknown_params(
|
||||
self,
|
||||
params: list[click.Parameter],
|
||||
) -> None:
|
||||
param_names = {param.name for param in params}
|
||||
has_changes = False
|
||||
|
||||
for key in list(self.config[self.section_name].keys()):
|
||||
if key not in param_names:
|
||||
self.config.remove_option(self.section_name, key)
|
||||
has_changes = True
|
||||
|
||||
if has_changes:
|
||||
self._write_config_file()
|
||||
|
||||
def parse_params_from_config(
|
||||
self,
|
||||
params: list[click.Parameter],
|
||||
|
||||
@@ -118,6 +118,7 @@ def load_config_file(
|
||||
return ctx
|
||||
|
||||
config_file = ConfigFile(ctx.params["config_path"])
|
||||
config_file.cleanup_unknown_params(ctx.command.params)
|
||||
config_file.add_params_default_to_config(
|
||||
ctx.command.params,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user