CLI Tools PluginΒΆ
Advanced development and automation tools for Structum framework.
OverviewΒΆ
The CLI Tools plugin extends the base Structum CLI with industry-grade features for security, testing, profiling, release automation, and more.
ArchitectureΒΆ
The plugin respects Structumβs Zero-Dependency philosophy by separating core from advanced tools:
ββββββββββββββββββββββββββββββββββββββββ
β structum (Meta Package) β
β ββ check (Ruff/Black) β β Zero-Dep Core
β ββ build-docs (Sphinx) β
β ββ license (REUSE) β
ββββββββββββββββββββββββββββββββββββββββ€
β structum-cli-tools (This Plugin) β
β ββ security (Bandit, Safety) β β Batteries-Included
β ββ test (pytest, coverage) β
β ββ profile (py-spy, memory) β
β ββ release (semantic-release) β
β ββ api (griffe) β
β ββ plugin (marketplace) β
β ββ validate (contract testing) β
β ββ i18n (babel) β
β ββ telemetry (opt-in analytics) β
ββββββββββββββββββββββββββββββββββββββββ
Auto-Discovery: Commands automatically register when plugin is installed (via entry points).
InstallationΒΆ
With Meta PackageΒΆ
# Recommended: Full tooling
pip install structum structum-cli-tools
StandaloneΒΆ
# Plugin only (requires structum)
pip install structum-cli-tools
DevelopmentΒΆ
# Clone repository
git clone https://github.com/PythonWoods/structum.git
cd structum
# Install with workspace
uv sync --extra dev
FeaturesΒΆ
π Security ScanningΒΆ
Static code analysis + dependency vulnerability checking:
structum security scan # Bandit code scan
structum security audit # Full audit (Bandit + Safety)
structum security report -o sec.json # JSON report
See: :doc:/cli/security | :doc:/security/scanning
π§ͺ Testing & CoverageΒΆ
pytest integration with enforced thresholds:
structum test # Run tests
structum test --cov # With coverage
structum test --cov --cov-fail-under=90 # Enforce 90%
Configuration: .coveragerc, pyproject.toml [tool.pytest]
See: :doc:/cli/testing
β‘ Performance ProfilingΒΆ
CPU and memory profiling for optimization:
structum profile run app.py # CPU profiling
structum profile memory app.py # Memory tracking
structum profile benchmark # Run benchmarks
Tools: py-spy, memory_profiler, pytest-benchmark
See: :doc:/cli/profiling
π Release AutomationΒΆ
Semantic versioning and changelog generation:
structum release prepare # Bump version + changelog
structum release validate # Pre-release checks
structum release publish # Publish to PyPI
Based on: Conventional Commits, semantic-release
See: :doc:/cli/release | :doc:/contributing/releasing
π API StabilityΒΆ
Detect breaking changes in public API:
structum api diff v0.1.0..HEAD # Compare versions
structum api validate # Check current API
Tool: griffe (Python API inspector)
See: :doc:/cli/api
π Plugin MarketplaceΒΆ
Discover and install community plugins:
structum plugin search redis # Search plugins
structum plugin install structum-redis # Install
structum plugin verify structum-redis # Verify signatures
Registry: registry/plugins.json (GitHub Pages)
See: :doc:/cli/plugins | :doc:/plugins/marketplace
β Contract TestingΒΆ
Validate plugin compliance with protocols:
structum validate plugin packages/auth/
structum validate all
Validates: Protocol implementation, type safety
See: :doc:/cli/validation | :doc:/plugins/development
π InternationalizationΒΆ
Multi-language CLI support:
structum i18n extract # Extract messages
structum i18n compile # Compile .mo files
structum --lang=it check # Italian messages
Platform: GNU gettext + Babel
See: :doc:/cli/i18n | :doc:/contributing/i18n
π Telemetry (Opt-in)ΒΆ
Privacy-first anonymous analytics:
structum telemetry enable # Opt-in
structum telemetry status # Check status
structum telemetry disable # Opt-out
Whatβs collected: Command usage, error types (NO personal data)
See: :doc:/cli/telemetry | :doc:/privacy/policy
DevelopmentΒΆ
Adding New CommandsΒΆ
Create module in
src/structum/plugins/cli_tools/:
# src/structum/plugins/cli_tools/mycommand.py
import typer
mycommand_app = typer.Typer(
name="mycommand",
help="My new command",
)
@mycommand_app.command()
def run():
"""Run my command."""
print("Hello!")
Register in
__init__.py:
def register_commands(app: typer.Typer) -> None:
from structum.plugins.cli_tools.mycommand import mycommand_app
app.add_typer(mycommand_app, name="mycommand")
Document:
Add
docs/cli/mycommand.rstUpdate
docs/cli/index.mdAdd cross-references
Test:
Create
tests/cli_tools/test_mycommand.pyVerify help text
Integration test
Architecture DetailsΒΆ
Entry PointsΒΆ
Plugin registration via pyproject.toml:
[project.entry-points."structum.cli_plugins"]
cli_tools = "structum.plugins.cli_tools:register_commands"
Auto-DiscoveryΒΆ
Meta CLI loads plugins automatically:
# In structum.cli (Meta package)
from importlib.metadata import entry_points
for ep in entry_points(group="structum.cli_plugins"):
register_func = ep.load()
register_func(app)
Graceful DegradationΒΆ
If plugin not installed, commands unavailable but no errors:
$ structum security scan
# Without structum-cli-tools:
# Error: Unknown command 'security'
# Install with: pip install structum-cli-tools
DependenciesΒΆ
SecurityΒΆ
bandit[toml]>=1.7.5- Code vulnerability scannersafety>=3.0.0- Dependency CVE checker
TestingΒΆ
pytest>=7.4.0- Test frameworkpytest-cov>=4.1.0- Coverage plugincoverage[toml]>=7.3.0- Coverage measurement
ProfilingΒΆ
py-spy>=0.3.14- Sampling profilermemory-profiler>=0.61.0- Memory trackingpytest-benchmark>=4.0.0- Benchmarking
ReleaseΒΆ
python-semantic-release>=8.5.0- Semantic versioningtowncrier>=23.11.0- Changelog generation
OthersΒΆ
griffe>=0.38.0- API inspectionrequests>=2.31.0- HTTP client (marketplace)keyring>=24.3.0- Secure credential storagebabel>=2.14.0- Internationalization
ContributingΒΆ
See main CONTRIBUTING for guidelines.
Plugin-specific:
All commands must have comprehensive docstrings
Sphinx cross-references required
Examples in both docstrings and
.rstfilesUnit tests + integration tests
Ruff/Black compliant
LicenseΒΆ
Apache-2.0 - See LICENSE
See AlsoΒΆ
:doc:
/cli/index- Complete CLI reference:doc:
/plugins/development- Plugin development guide:doc:
/architecture/cli-design- CLI plugin system design:mod:
structum.cli- Base CLI module:mod:
structum.plugins.cli_tools- Plugin API reference