Skip to main content

Class based argument parser

Project description

Class-Argparse

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

How to use

class Main(ClassArgParser):

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

    async def foo(self, first: str):
        print(f"foo, first={first}")

    def bar(self):
        print("bar")

    async def baz(self, first: str, second: int):
        print(f"baz, first={first}, second={second}")


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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

class-argparse-0.1.1.tar.gz (3.1 kB view hashes)

Uploaded Source

Built Distribution

class_argparse-0.1.1-py3-none-any.whl (3.5 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page