Skip to main content

Class-Argparse

Class based argument parser to simplify writing CLIs that have lots of options

How to use

from typing import Literal

from class_argparse import ClassArgParser


class Main(ClassArgParser):
    """
    # ClassArgParser
    example description
    """

    def __init__(self) -> None:
        super().__init__(name="Class ArgParser")

    def no_args(self):
        print("no_args")

    def no_args_with_desc(self):
        """
        some desc text goes here
        second line of desc
        """
        print("no_args_with_desc")

    def some_args(self, arg: str):
        print("some_args", arg)

    def default_values(self, arg: str, default: int = 0):
        print("default_values", arg, default)

    def list_values(self, values: list[str]):
        print("list_values", values)

    def untyped_arg(self, untyped):
        print("untyped_arg", untyped)

    async def async_func(self, arg: str):
        print("async_func", arg)

    def literal_options(self, arg: Literal["a", "b"]):
        print("literal_options", arg)


if __name__ == "__main__":
    Main()()

How this works

  1. The class ClassArgParser extends ArgumentParser
  2. The initialization function finds add adds all the methods on child classes that are public i.e. their names don't start with __
  3. The object of the class is called and after identifying whether the function being called it is async or sync it runs the function accordingly

Metadata

Release files for class-argparse 0.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for class-argparse 0.1.4
File Size Uploaded
class_argparse-0.1.4.tar.gz 3.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for class-argparse 0.1.4
File Interpreter ABI Platform
class_argparse-0.1.4-py3-none-any.whl Python 3 none any Details

Total release size: 7.9 kB

Release files / class_argparse-0.1.4.tar.gz

Download URL class_argparse-0.1.4.tar.gz
Size 3.7 kB
Tags Source
SHA-256 checksum
How to use checksums
714a99880b188133e1023d78e5a95e4b6391b1d9253a179f0e4c94c4fa82610a
BLAKE2b-256 checksum
How to use checksums
f847c0ee0960f0172a6830da300a818921ea59d41ccab8507539c0a54a617fe2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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 Sep 21, 2025.

Transparency log

Release files / class_argparse-0.1.4-py3-none-any.whl

Download URL class_argparse-0.1.4-py3-none-any.whl
Size 4.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ed89b63fbf761f6ef8d8c77b00c2705b1457c6044946cc676d766f3995253a65
BLAKE2b-256 checksum
How to use checksums
532c1ebeeeb8f2a6da1889d1c2dae87c10b66dc4e3ae6622dd8b672eda0498d7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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 Sep 21, 2025.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.4 This release

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page