Add default handling and write functionality to `ConfigManager`

- Ensure missing or empty config values are replaced with defaults.
- Write updated configuration back to `config.toml` using `tomli_w`.
This commit is contained in:
Gustavo Henrique Santos Souza de Miranda 2025-10-31 00:27:33 -03:00
parent e8d5159973
commit 59178d3cec
1 changed files with 10 additions and 0 deletions

View File

@ -54,3 +54,13 @@ class ConfigManager(metaclass=SingletonMeta):
} }
for key, default_value in default.items():
current_value = self.__data.get(key)
if current_value is None or current_value == "":
self.__data[key] = default_value
else:
self.__data[key] = current_value
with open(f"{self.config_dir}/config.toml", "wb") as f:
tomli_w.dump(self.__data, f)