From 17e7a32c563233282b42bbf307479e74c8fa2dff Mon Sep 17 00:00:00 2001 From: majh Date: Thu, 14 Mar 2024 20:51:06 +0000 Subject: [PATCH] small improvements --- conflator/conflator.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/conflator/conflator.py b/conflator/conflator.py index 14fadc8..afd6426 100644 --- a/conflator/conflator.py +++ b/conflator/conflator.py @@ -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", ] @@ -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 @@ -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 @@ -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