Skip to main content

basecmd

Logging boilerplate for the command line.

Classes inheriting from BaseCmd get a self.log attribute — a standard Python logging.Logger — pre-configured to sys.stdout with color support when logging to a terminal.

Quick start

from basecmd import BaseCmd


class MyCmd(BaseCmd):
    "Demo command"

    def add_arguments(self):
        self.parser.add_argument("--foo", help="Custom option")

    def __call__(self):
        self.log.debug("options: %s", self.options)


if __name__ == "__main__":
    cmd = MyCmd()
    cmd()

Run with -h / --help to see the built-in logging options:

usage: __main__.py [-h] [-v {error,warning,info,debug}] [--log-file LOG_FILE]
                   [--foo FOO]

Configuration

Defaults can be set via environment variables or a .env file:

Variable Description Default
LOG_LEVEL Logging verbosity: error, warning, info, or debug info
LOG_FILE Path to a log file; stdout when unset None (stdout)
LOG_FORMAT Python logging format string unset → %(asctime).19s %(message)s

Release files for basecmd 0.1.9

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for basecmd 0.1.9
File Size Uploaded
basecmd-0.1.9.tar.gz 3.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for basecmd 0.1.9
File Interpreter ABI Platform
basecmd-0.1.9-py3-none-any.whl Python 3 none any Details

Total release size: 8.0 kB

Release files / basecmd-0.1.9.tar.gz

Download URL basecmd-0.1.9.tar.gz
Size 3.7 kB
Tags Source
SHA-256 checksum
How to use checksums
1ba26d60e92d4e697c1868a5b9f599a31e7c17a5c826926e009997bf4593a2f1
BLAKE2b-256 checksum
How to use checksums
41094bb7a73eb36e61ce1f81304e28439653c8bda394bbc77e05726dcbe96568
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.32 {"installer":{"name":"uv","version":"0.11.32","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / basecmd-0.1.9-py3-none-any.whl

Download URL basecmd-0.1.9-py3-none-any.whl
Size 4.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7faa335aeff1d4235df50386d01b0c89058dbb2b831bc732769c492166b5ce73
BLAKE2b-256 checksum
How to use checksums
7d49c87d69e4fb17aa71d5ac6e4485f103a600ff56252c6a3b150a06dcf4e305
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.32 {"installer":{"name":"uv","version":"0.11.32","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

0.1.10

2 release files

This release

0.1.9 This release

2 release files

0.1.8

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page