# src/ctf/config.py
# {{{ imports
import toml
from pathlib import Path
from platformdirs import user_config_dir
# }}}

# {{{ load_config
def load_config(config = f"{user_config_dir()}/ctf-config.toml") -> dict:
    p = Path(config)
    if p.exists():
        return toml.load(p)
    return {}
# }}}

# {{{ write_config
def write_config(data: dict, config = f"{user_config_dir()}/ctf"):
    with open(config, "w") as f:
        toml.dump(data, f)
# }}}

# {{{ exports
config_data = load_config("/home/venus/code/ctf/config.toml")
competition = config_data.get("Competition", {})
enviroment = config_data.get("Enviroment", {})
# }}}
