diff --git a/src/gallia/cli.py b/src/gallia/cli.py index 7c726630a..1c2f436c9 100644 --- a/src/gallia/cli.py +++ b/src/gallia/cli.py @@ -325,7 +325,12 @@ def main() -> None: for fn in load_cli_init_plugins(): fn(parsers) - config, config_path = load_config_file() + try: + config, config_path = load_config_file() + except ValueError as e: + print(f"invalid config: {e}") + sys.exit(1) + build_cli(parsers, config, registry) parser = parsers["parser"] diff --git a/tests/test_config.py b/tests/test_config.py index 5502eac1d..4e33942b2 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -76,3 +76,15 @@ def test_get_value(tmp_path: Path) -> None: config, _ = load_config_file() assert config.get_value("gallia.foobar.baz") == "fiz" + + +def test_invalid_config(tmp_path: Path) -> None: + config_file = tmp_path.joinpath("gallia.toml") + config_file.write_text( + """[gallia.foobar] +baz = fiz +""" + ) + + with pytest.raises(ValueError): + load_config_file(config_file)