Quickparser
Create lightweight CLI arg parsers from pydantic models.
This provides a clean, declarative way to create a command-line interface by allowing you to define the interface using Pydantic models.
For example,
from pydantic import BaseModel, Field
from quickparser import parser
@parser
class SimpleModel(BaseModel):
"""
Example CLI for demonstration.
"""
name: str
age: int = Field(default=30)
hobby: str | None
employed: bool
args = SimpleModel.parse()
Is the equivalent of the following argparse code:
import argparse
parser = argparse.ArgumentParser(description="Example CLI for demonstration.")
parser.add_argument("--name", type=str, required=True)
parser.add_argument("--age", type=int, default=30)
parser.add_argument("--hobby", type=str, default=None)
parser.add_argument("--employed", action="store_true")
args = parser.parse_args()
Installation
pip install quickparser
Usage
We can take the example above and put it into an example.py script to demonstrate the basic usage:
# example.py
from pydantic import BaseModel, Field
from quickparser import parser
@parser
class SimpleModel(BaseModel):
"""
Example CLI for demonstration.
"""
name: str
age: int = Field(default=30)
hobby: str | None
employed: bool
if __name__ == "__main__":
args = SimpleModel.parse()
print(args)
This script can be run from the command line, and it will parse the arguments provided to it. For example:
python example.py --name John --age 25 --hobby "reading" --employed
This will output:
SimpleModel(name='John', age=25, hobby='reading', employed=True)
Built on top of argparse, the parser provided automatically includes a help message,
type casting based on type hints, default values, and required vs optional arguments.
Help can be accessed by running the script with the --help flag:
python example.py --help
Metadata
Release files for quickparser 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| quickparser-0.1.2.tar.gz | 4.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| quickparser-0.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 8.0 kB
Release files / quickparser-0.1.2.tar.gz
| Download URL | quickparser-0.1.2.tar.gz |
|---|---|
| Size | 4.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c63d373554082a030facc37ef7ba3d148addff95de2081ff670c79c444a7689b
|
|
BLAKE2b-256 checksum How to use checksums |
0d04f0ffba4c744fa160bcc7cfb0457ab466ced6e2afdce2a48d5eadb7465773
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 26, 2025.
Transparency logRelease files / quickparser-0.1.2-py3-none-any.whl
| Download URL | quickparser-0.1.2-py3-none-any.whl |
|---|---|
| Size | 3.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
14ce1550a4b167bbc9f0745a19338e5c933a3d41229f35b2e5a32646409c9266
|
|
BLAKE2b-256 checksum How to use checksums |
537516a5aa184aa105e55672e11baebcc766126e6e91dddb2a0b796bc9c277c3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 26, 2025.
Transparency log