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 details)

Uploaded Source

Built Distribution

pr0cks_extension-0.1.0-py3-none-any.whl (15.9 kB view details)

Uploaded Python 3

File details

Details for the file pr0cks_extension-0.1.0.tar.gz.

File metadata

  • Download URL: pr0cks_extension-0.1.0.tar.gz
  • Upload date:
  • Size: 14.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.5 CPython/3.6.9 Linux/4.15.0-100-generic

File hashes

Hashes for pr0cks_extension-0.1.0.tar.gz
Algorithm Hash digest
SHA256 82e929f406daf45b123420fd3236d4da2b505f8bdd9cdb4ff7e02db80eccd7dd
MD5 d3a9c9395a36ffece0fc026c7bb2754f
BLAKE2b-256 ea93770a2029f58f55d19d84f72761079ad037c17460fe22835b6ad717bc5ded

See more details on using hashes here.

File details

Details for the file pr0cks_extension-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pr0cks_extension-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 15.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.5 CPython/3.6.9 Linux/4.15.0-100-generic

File hashes

Hashes for pr0cks_extension-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7f420f450780cfae0bc2521e1c1f919519ef51e1c17b89f8ef5691aa19bd84f4
MD5 5c54af9af596ff2b83147d36ada28ce7
BLAKE2b-256 79abcd1fc8a3016317757953ae6d125baa72314ca65525420881aeb3c341af9a

See more details on using hashes here.

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