Skip to main content

Build Config classes that can be quickly turned into CLI specifications

Project description


Python 3.6+ utility to build Classes that can be easily modified to create a Python Argparse specification. The goal of this is to couple a CLI specification to a config class, making them quicker to build and less likely to break.

This leans heavily on the Decli library to generate Argparse specifications.

from doccli import DocliParser

class CliTool:
    def __init__(self, _non_cli_param: str, param_a: str, param_b: int = 5):
        """Some CLI Tool description. 

        Note that only the short description is included in the parser description
            _non_cli_param (str): Underscore leading params aren't included in the
                                  CLI specs
            param_a (str): A required parameter 
            param_b (int, optional): This one has a default

        self.param_a = param_a
        self.param_b = param_b

        self.non_cli_param = non_cli_param

# This creates a Decli Specification 
parser_spec = DocliParser.create_decli_spec(CliTool)

assert parser_spec == {
    "prog": "CliTool",
    "description": "Some CLI Tool description",
    "arguments": [
            "name": "--param-a",
            "type": str,
            "help": "A required parameter",
            "name": "--param-b",
            "type": int,
            "default": 5,
            "help": "This one has a default",

# To create the argparse object:
parser = DocliParser(CliTool)

See examples for more examples.

Project details

Download files

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

Files for doc-cli, version 0.0.1
Filename, size File type Python version Upload date Hashes
Filename, size doc_cli-0.0.1-py3-none-any.whl (7.1 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size doc-cli-0.0.1.tar.gz (6.9 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page