Skip to content

Commit

Permalink
small improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
jameshawkes committed Mar 14, 2024
1 parent 47f963d commit 17e7a32
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions conflator/conflator.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ def __init__(
]
if config_file is not None
else [
Path() / "etc" / self.app_name / "config.json",
Path() / "etc" / self.app_name / "config.yaml",
Path("/") / "etc" / self.app_name / "config.json",
Path("/") / "etc" / self.app_name / "config.yaml",
Path.home() / f".{self.app_name}.json",
Path.home() / f".{self.app_name}.yaml",
]
Expand Down Expand Up @@ -128,7 +128,10 @@ def _get_cli_args(model: Type[BaseModel], args: set[CLIArg] = None):
# TODO: model_title = model.model_config.get("title") or model.__name__
for k, v in model.model_fields.items():
cli_args = [m for m in v.metadata if isinstance(m, CLIArg)]
description = v.description or ""

for ca in cli_args:
ca.description = description
args.add(ca)
return args

Expand Down Expand Up @@ -208,6 +211,7 @@ def load(self) -> BaseModel:
for err in e.errors():
output.add(f"[red]{err['msg'].upper()}:[/red][cyan] {self._loc_to_dot_sep(err['loc'])}[/cyan]")
rprint(output)
rprint(f"[red]Use --help for more information.[/red]")
raise SystemExit(e.error_count())

return result
Expand Down Expand Up @@ -294,7 +298,7 @@ def _update_from_cli_args(self):
self.parser = argparse.ArgumentParser(
description=f"All arguments can be overriden with {self.app_name.upper()}_ARG."
+ f"They can also be set in JSON files: /etc/{self.app_name}/config.json and ~/.{self.app_name}apirc"
+ [f" - {cf}" for cf in self.config_files],
+ [f" - {cf.resolve()}" for cf in self.config_files],
formatter_class=RawTextRichHelpFormatter,
)
# Add arguments based on Pydantic model fields
Expand Down

0 comments on commit 17e7a32

Please sign in to comment.