click-config-file-injection-utils
Table of Contents
1. Introduction
Utilities for building Click CLIs that load option defaults from user-specified
TOML files. The package exposes a single callback function,
injectDefaultOptionsFromToml and the exception MissingToolSectionError.
The config options in the TOML file are injected as the default config options, which can be overwritten by any CLI-specified configs. If users don't specify corresponding configs from CLI, these TOML config options will be actually applied to the CLI tool.
2. Installation Instruction
pip install click-config-file-injection-utils
3. Usage
Here is how you can use it with Click:
import click
from click_config_file_injection_utils import injectDefaultOptionsFromToml
@click.command()
@click.option(
'--config',
callback=lambda ctx, param, value: injectDefaultOptionsFromToml(
ctx,
param,
value,
toolSectionName='demo',
),
)
@click.option('--count', default=1, show_default=True)
def cli(count: int, config: str | None) -> None:
click.echo(f'count={count}')
if __name__ == '__main__':
cli()
If the user runs cli --config pyproject.toml and that file contains
[tool.demo] count = 5, the command prints count=5. Passing --count on the
CLI still overrides the TOML value.
The helper mirrors the behavior currently used in the pydoclint CLI, but it
can be reused by any Click application that maintains its configuration under a
[tool.<name>] table.
Metadata
Release files for click-config-file-injection-utils 0.1.1
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 |
|---|---|---|---|---|
| click_config_file_injection_utils-0.1.1.tar.gz | 5.7 kB | Without provenance | Details for click_config_file_injection_utils-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| click_config_file_injection_utils-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for click_config_file_injection_utils-0.1.1-py3-none-any.whl |
Total release size: 12.2 kB
Release files / click_config_file_injection_utils-0.1.1.tar.gz
| Download URL | click_config_file_injection_utils-0.1.1.tar.gz |
|---|---|
| Size | 5.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
94c95f603534242e5f80e98390eb4063b3db29e6bfcb1b80831a92102884c7c3
|
|
BLAKE2b-256 checksum How to use checksums |
b743407f3cfc912ed56e0e06b6f2a5a817d37d04ac76e755b99e647333b38abb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.24
|
Release files / click_config_file_injection_utils-0.1.1-py3-none-any.whl
| Download URL | click_config_file_injection_utils-0.1.1-py3-none-any.whl |
|---|---|
| Size | 6.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1875cd8f59768365290560adffb71255173a9728b741d9c02603ca618b51376c
|
|
BLAKE2b-256 checksum How to use checksums |
4f8e44bbc4e125275afd8efed0f6cf6d2f265c7562898a2f348daba75afcdc08
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.24
|
Security for click-config-file-injection-utils 0.1.1
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.