Skip to main content

Basis for CLI extensions for pr0cks

Project description

pr0cks-extension

The base package for extensions to pr0cks to inherit from.

Extensions are discovered using setuptools' entrypoint feature. They can also be declared in poetry.

For now the only type of extension that exists is a CLI extension. It allows adding parameters to the pr0cks CLI.

Writing a basic extension

The easiest way is to start a project with poetry using poetry init.

It would be convention to prefix the project name with pr0cks-. For this example let's call it pr0cks-debug which will have the sole task of adding the --debug param and thus alias --verbose.

import argparse
import logging

from pr0cks_extension.cli import Pr0cksCommand

class DebugCommand(Pr0cksCommand):
    NAME = "debug"  # Will be used as the name of argparse group
    
    def _add_args(self):
        """Adds arguments to the argparse group"""
        self.arg_group.add_argument(
            "--debug",
            action="store_true",
            help="Activate debug logging"
)       
    
    def execute(self, args: argparse.Namespace, bind_address: str):
        """Activates debug logging for pr0cks"""
        logging.getLogger().setLevel(logging.DEBUG)

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

pr0cks_extension-0.1.0.tar.gz (14.9 kB view hashes)

Uploaded Source

Built Distribution

pr0cks_extension-0.1.0-py3-none-any.whl (15.9 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