diff options
author | Romain Gonçalves <me@rgoncalves.se> | 2022-10-08 14:08:16 +0200 |
---|---|---|
committer | Romain Gonçalves <me@rgoncalves.se> | 2022-10-08 14:08:16 +0200 |
commit | 037ab915bd455cccf46391f02f61949e5c84f1c3 (patch) | |
tree | 65a93d90a540a6e53fc6e618a9904529060964ca /README.md | |
parent | e667cd7e2dd0a7ac14ac30db38ca630ec0c5409b (diff) | |
download | pydanclick-037ab915bd455cccf46391f02f61949e5c84f1c3.tar.gz |
wip: saturday fixup
Diffstat (limited to 'README.md')
-rw-r--r-- | README.md | 53 |
1 files changed, 53 insertions, 0 deletions
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() │ +└────────────────────────────────────┘ +``` |