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
Release history Release notifications | RSS feed
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)
Built Distribution
Close
Hashes for pr0cks_extension-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7f420f450780cfae0bc2521e1c1f919519ef51e1c17b89f8ef5691aa19bd84f4 |
|
MD5 | 5c54af9af596ff2b83147d36ada28ce7 |
|
BLAKE2b-256 | 79abcd1fc8a3016317757953ae6d125baa72314ca65525420881aeb3c341af9a |