Skip to content

Commit

Permalink
Improve config file setup and error handling.
Browse files Browse the repository at this point in the history
  • Loading branch information
felixfontein committed Aug 19, 2022
1 parent ba624d5 commit cc674ca
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ antsibull-lint = "antsibull.cli.antsibull_lint:main"
[tool.poetry.dependencies]
python = "^3.6.1"
antsibull-changelog = ">= 0.14.0"
antsibull-core = ">= 1.0.0, < 2.0.0"
antsibull-core = ">= 1.2.0, < 2.0.0"
antsibull-docs = ">= 1.0.0, < 2.0.0"
asyncio-pool = "*"
jinja2 = "*"
Expand Down
11 changes: 8 additions & 3 deletions src/antsibull/cli/antsibull_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from antsibull_core.args import ( # noqa: E402
InvalidArgumentError, get_toplevel_parser, normalize_toplevel_options
)
from antsibull_core.config import load_config # noqa: E402
from antsibull_core.config import ConfigError, load_config # noqa: E402

from ..build_collection import build_collection_command # noqa: E402
from ..build_ansible_commands import ( # noqa: E402
Expand Down Expand Up @@ -384,14 +384,19 @@ def run(args: List[str]) -> int:
print(e)
return 2

cfg = load_config(parsed_args.config_file)
flog.fields(config=cfg).info('Config loaded')
try:
cfg = load_config(parsed_args.config_file)
flog.fields(config=cfg).info('Config loaded')
except ConfigError as e:
print(e)
return 2

context_data = app_context.create_contexts(args=parsed_args, cfg=cfg)
with app_context.app_and_lib_context(context_data) as (app_ctx, dummy_):
twiggy.dict_config(app_ctx.logging_cfg.dict())
flog.debug('Set logging config')

flog.fields(command=parsed_args.command).info('Action')
return ARGS_MAP[parsed_args.command]()


Expand Down

0 comments on commit cc674ca

Please sign in to comment.