{"id":45824649,"url":"https://github.com/python-project-templates/p2a","last_synced_at":"2026-02-26T21:49:39.238Z","repository":{"id":323735907,"uuid":"1093917538","full_name":"python-project-templates/p2a","owner":"python-project-templates","description":"pydantic models to argparse CLIs","archived":false,"fork":false,"pushed_at":"2026-02-15T05:56:27.000Z","size":35,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-02-15T12:31:47.178Z","etag":null,"topics":["argparse","cli","model","pydantic","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/python-project-templates.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-11-11T02:34:30.000Z","updated_at":"2026-02-15T05:56:30.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/python-project-templates/p2a","commit_stats":null,"previous_names":["python-project-templates/p2a"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/python-project-templates/p2a","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/python-project-templates%2Fp2a","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/python-project-templates%2Fp2a/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/python-project-templates%2Fp2a/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/python-project-templates%2Fp2a/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/python-project-templates","download_url":"https://codeload.github.com/python-project-templates/p2a/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/python-project-templates%2Fp2a/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29873809,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-26T21:05:00.265Z","status":"ssl_error","status_checked_at":"2026-02-26T20:57:13.669Z","response_time":89,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["argparse","cli","model","pydantic","python"],"created_at":"2026-02-26T21:49:38.546Z","updated_at":"2026-02-26T21:49:39.224Z","avatar_url":"https://github.com/python-project-templates.png","language":"Python","readme":"# p2a\n\npydantic models to argparse CLIs\n\n[![Build Status](https://github.com/python-project-templates/p2a/actions/workflows/build.yaml/badge.svg?branch=main\u0026event=push)](https://github.com/python-project-templates/p2a/actions/workflows/build.yaml)\n[![codecov](https://codecov.io/gh/python-project-templates/p2a/branch/main/graph/badge.svg)](https://codecov.io/gh/python-project-templates/p2a)\n[![License](https://img.shields.io/github/license/python-project-templates/p2a)](https://github.com/python-project-templates/p2a)\n[![PyPI](https://img.shields.io/pypi/v/p2a.svg)](https://pypi.python.org/pypi/p2a)\n\n## Overview\n\nA function is provided to automatically expose fields as command line arguments.\n\n```python\nimport sys\nfrom pydantic import BaseModel\nfrom p2a import parse_extra_args_model\n\n\nclass MyPluginConfig(BaseModel, validate_assignment=True):\n    extra_arg: bool = False\n    extra_arg_with_value: str = \"default\"\n    extra_arg_literal: Literal[\"a\", \"b\", \"c\"] = \"a\"\n\n\nmodel = MyPluginConfig()\nparse_extra_args_model(model, sys.argv)\n\n# \u003e my-cli --extra-arg --extra-arg-with-value \"test\" --extra-arg-literal b\n```\n\nFor integration with existing `argparse` CLIs, a helper function to create an `argparse.SubParser` is also provided: `p2a.create_model_parser`.\n\n\u003e [!NOTE]\n\u003e This library was generated using [copier](https://copier.readthedocs.io/en/stable/) from the [Base Python Project Template repository](https://github.com/python-project-templates/base).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpython-project-templates%2Fp2a","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpython-project-templates%2Fp2a","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpython-project-templates%2Fp2a/lists"}