From 037ab915bd455cccf46391f02f61949e5c84f1c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Gon=C3=A7alves?= Date: Sat, 8 Oct 2022 14:08:16 +0200 Subject: wip: saturday fixup --- README.md | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 README.md (limited to 'README.md') diff --git a/README.md b/README.md new file mode 100644 index 0000000..01a8ac0 --- /dev/null +++ b/README.md @@ -0,0 +1,53 @@ +Leverage the power of `pydantic` to create `click` command line applications! + +# Getting started + +Invoke the example module: + +``` +$ python -m pydanclick.examples --help +``` + +# Architecture + +``` +┌─────────────────────────────────────────────────┐ +│ Pydantic Schema │ +├─────────────────────────────────────────────────┤ +│ class MainArguments(BaseModel): │ +│ verbose: bool │ +│ name: str = Field(description="Service name.")│ +│ ... │ +└──┬──▲───────────────────────────────────────────┘ + │ │ + │ │ + │ │ Reads schema + │ │ + generate click interface + │ ┌┴────────────────────────┐ + │ │ Pydanclick decorator ├─────────────────────────────┐ + │ ├─────────────────────────┤ │ + │ │ pydanclick.core.command │ │ + │ │ pydanclick.core.group │ │ + │ └─────────────────────────┘ │ + │ │ +┌──▼───────────────────────────────────────────────────────┐ │ +│ Click Interface │ │ +├──────────────────────────────────────────────────────────┤ │ +│ click.Option("--verbose", required=True, type=click.BOOL)│ │ +│ type=click.BOOL) │ │ +│ click.Option("--name", required=True, │ │ +│ type=click.STR, │ │ +│ help="Service Name.") │ │ +└──────────────────────────────────────────────────────────┘ │ + │ +┌────────────────────────────────────┐ │ +│ Entrypoint invocation │◄──────────────────────┘ +├────────────────────────────────────┤ Read annotation(s) +│ @command() │ + invoke with arguments +│ def main(parameter: MainArguments):│ from click +│ ... │ +│ │ +│ if __name__ == "__main__": │ +│ main() │ +└────────────────────────────────────┘ +``` -- cgit v1.2.3