
Security News
Crates.io Implements Trusted Publishing Support
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
Helpers to build a CLI program and some useful tools for CLI programs.
pip install cli-base-utilities
Some of the features are:
TODO: Document all features here ;)
~$ git clone https://github.com/jedie/cli-base-utilities.git
~$ cd cli-base-utilities
~/cli-base-utilities$ ./dev-cli.py --help
usage: ./dev-cli.py [-h]
{check-code-style,coverage,fix-code-style,install,mypy,nox,pip-audit,publish,t
est,update,update-test-snapshot-files,version}
╭─ options ──────────────────────────────────────────────────────────────────────────────────────╮
│ -h, --help show this help message and exit │
╰────────────────────────────────────────────────────────────────────────────────────────────────╯
╭─ subcommands ──────────────────────────────────────────────────────────────────────────────────╮
│ {check-code-style,coverage,fix-code-style,install,mypy,nox,pip-audit,publish,test,update,updat │
│ e-test-snapshot-files,version} │
│ check-code-style │
│ Check code style by calling darker + flake8 │
│ coverage Run tests and show coverage report. │
│ fix-code-style │
│ Fix code style of all cli_base source code files via darker │
│ install Run pip-sync and install 'cli_base' via pip as editable. │
│ mypy Run Mypy (configured in pyproject.toml) │
│ nox Run nox │
│ pip-audit Run pip-audit check against current requirements files │
│ publish Build and upload this project to PyPi │
│ test Run unittests │
│ update Update "requirements*.txt" dependencies files │
│ update-test-snapshot-files │
│ Update all test snapshot files (by remove and recreate all snapshot files) │
│ version Print version and exit │
╰────────────────────────────────────────────────────────────────────────────────────────────────╯
usage: ./cli.py [-h] {update-readme-history,version}
╭─ options ──────────────────────────────────────────────────────────────────────────────────────╮
│ -h, --help show this help message and exit │
╰────────────────────────────────────────────────────────────────────────────────────────────────╯
╭─ subcommands ──────────────────────────────────────────────────────────────────────────────────╮
│ {update-readme-history,version} │
│ update-readme-history │
│ Update project history base on git commits/tags in README.md Will be exited │
│ with 1 if the README.md was updated otherwise with 0. │
│ │
│ Also, callable via e.g.: │
│ python -m cli_base update-readme-history -v │
│ version Print version and exit │
╰────────────────────────────────────────────────────────────────────────────────────────────────╯
usage: ./demo-cli.py [-h]
{demo-endless-loop,demo-verbose-check-output-error,edit-settings,print-settin
gs,systemd-debug,systemd-logs,systemd-remove,systemd-setup,systemd-status,systemd-stop,version}
╭─ options ──────────────────────────────────────────────────────────────────────────────────────╮
│ -h, --help show this help message and exit │
╰────────────────────────────────────────────────────────────────────────────────────────────────╯
╭─ subcommands ──────────────────────────────────────────────────────────────────────────────────╮
│ {demo-endless-loop,demo-verbose-check-output-error,edit-settings,print-settings,systemd-debug, │
│ systemd-logs,systemd-remove,systemd-setup,systemd-status,systemd-stop,version} │
│ demo-endless-loop │
│ Just a useless example command, used in systemd DEMO: It just print some │
│ information in a endless loop. │
│ demo-verbose-check-output-error │
│ DEMO for a error calling │
│ cli_base.cli_tools.subprocess_utils.verbose_check_output() │
│ edit-settings │
│ Edit the settings file. On first call: Create the default one. │
│ print-settings │
│ Display (anonymized) MQTT server username and password │
│ systemd-debug │
│ Print Systemd service template + context + rendered file content. │
│ systemd-logs List and follow logs of systemd service. (May need sudo) │
│ systemd-remove │
│ Write Systemd service file, enable it and (re-)start the service. (May need │
│ sudo) │
│ systemd-setup │
│ Write Systemd service file, enable it and (re-)start the service. (May need │
│ sudo) │
│ systemd-status │
│ Display status of systemd service. (May need sudo) │
│ systemd-stop Stops the systemd service. (May need sudo) │
│ version Print version and exit │
╰────────────────────────────────────────────────────────────────────────────────────────────────╯
Add a test case similar to cli_base/tests/test_readme_history.py into your project.
Add the needed start
/end
comments into your README.
To make a new release, do this:
It's recommended to use git hookd (via pre-commit) to update the README.
For this, add in your pyproject.toml
:
[tool.cli_base]
version_module_name = "<your_package>" # Must provide the `__version__` attribute
Copy&paste .pre-commit-config.yaml into your project.
Add pre-commit
to your requirements and install the git hooks by:
.venv/bin/pre-commit install
.venv/bin/pre-commit autoupdate
Update version in .pre-commit-config.yaml
and make a release.
The Problem: The hooks are broken, if the "new" version is not tagged yet.
To create a release, it's possible to use all git commands (commit, push, etc) with --no-verify
to skip the hooks.
It's easier to temporarily uninstall the hooks, create the release and install the hooks again, e.g.:
.../cli-base-utilities$ .venv/bin/pre-commit uninstall
# ...bump version, commit, push, merge... create release...
.../cli-base-utilities$ .venv/bin/pre-commit install
cli_base.run_pip_audit.run_pip_audit()
works now with uv
base projects instead of pip-tools
.
__version__
from module./cli_base/demo/
FAQs
Helpers to bild a CLI program
We found that cli-base-utilities demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
Research
/Security News
Undocumented protestware found in 28 npm packages disrupts UI for Russian-language users visiting Russian and Belarusian domains.
Research
/Security News
North Korean threat actors deploy 67 malicious npm packages using the newly discovered XORIndex malware loader.