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]
CLI options
BaseCmd registers two logging options on the parser; subclasses add their own
via add_arguments:
| Flag | Description |
|---|---|
-v, --verbosity |
Logging verbosity: error, warning, info, debug |
--log-file |
Path to a log file; logs to stdout when unset |
After parsing, self.options holds the parsed arguments and self.parser the
ArgumentParser used to build them.
Configuration
Defaults can be set via environment variables or a .env file. These are read
once when the module is imported, so set them before importing BaseCmd:
| 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 |
Metadata
Release files for basecmd 0.1.10
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| basecmd-0.1.10.tar.gz | 3.9 kB | Without provenance | Details for basecmd-0.1.10.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| basecmd-0.1.10-py3-none-any.whl | Python 3 | none | any | Details for basecmd-0.1.10-py3-none-any.whl |
Total release size: 8.1 kB
Release files / basecmd-0.1.10.tar.gz
| Download URL | basecmd-0.1.10.tar.gz |
|---|---|
| Size | 3.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
81da942ff0b4717c11c11b3be561d82f8fb84168cb094616ef00115d1d22bff5
|
|
BLAKE2b-256 checksum How to use checksums |
e9a43e9eaf8a002f543067e04476c47ff5775f3d91a00891c2f8e9b7ad8316a5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","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.10-py3-none-any.whl
| Download URL | basecmd-0.1.10-py3-none-any.whl |
|---|---|
| Size | 4.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0f7424a45064130dad6505305091d54d03845690cec12c697944b8b36cd80c8c
|
|
BLAKE2b-256 checksum How to use checksums |
924154ee6d800cf5af70169c1eef1c15cf14e9c52b6507af28cda4e72223ce31
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","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}
|
Security for basecmd 0.1.10
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.