fix command line args

- move to a complet class singleton to avoid propagation errors
- remove legacy load confing precedure
This commit is contained in:
Jake 2024-09-05 15:33:00 +01:00
parent 93872b34d7
commit cb91670c7a
2 changed files with 9 additions and 14 deletions

View file

@ -16,7 +16,10 @@ class TabbyConfig:
developer: dict = {}
embeddings: dict = {}
def __init__(self, arguments: Optional[dict] = None):
def __init__(self):
pass
def load_config(self, arguments: Optional[dict] = None):
"""load the global application config"""
# config is applied in order of items in the list
@ -44,10 +47,10 @@ class TabbyConfig:
with open(str(config_path.resolve()), "r", encoding="utf8") as config_file:
return unwrap(yaml.safe_load(config_file), {})
except FileNotFoundError:
logger.info("The config.yml file cannot be found")
logger.info(f"The '{config_path.name}' file cannot be found")
except Exception as exc:
logger.error(
"The YAML config couldn't load because of "
f"The YAML config from '{config_path.name}' couldn't load because of "
f"the following error:\n\n{exc}"
)
@ -86,11 +89,3 @@ class TabbyConfig:
# Create an empty instance of the shared var to make sure nothing breaks
config: TabbyConfig = TabbyConfig()
def load_config(arguments: dict):
"""Load a populated config class on startup."""
global shared_config
shared_config = TabbyConfig(arguments)