Karma CLI Parsing SDK
ktools-python/kcli/README.mdkcli is the Python command-line parsing layer in the ktools ecosystem.
It supports two complementary CLI shapes:
- top-level options such as
--verbose - inline roots such as
--build-*,--trace-*, or--config-*
The Python implementation follows the same core model as the C++ SDK:
Parserfor top-level options, aliases, and positionalsInlineParserfor one inline root such as--build- full-parse validation before any registered handler executes
parseOrExit()for executable-style handling andparseOrThrow()for tests and custom error handling
Documentation
Build And Test
Build from the ktools-python/ workspace root with the shared build tool:
python3 ../kbuild/kbuild.py --batch kcli --build-latest
If kbuild is already on your PATH, the equivalent command is:
kbuild --batch kcli --build-latest
From this repo root, run the Python tests directly:
python3 -m unittest discover -s tests
python3 -m unittest discover -s demo/tests
Demo entrypoints from this repo root:
python3 demo/bootstrap/main.py --verbose
python3 demo/exe/core/main.py --alpha-message hello
python3 demo/exe/omega/main.py --newgamma-tag prod
python3 demo/exe/omega/main.py --build
Behavior Highlights
parseOrExit()reports[error] [cli] ...tostderrand exits with code2parseOrThrow()raiseskcli.CliError- bare inline roots such as
--alphaor--buildprint inline help by default - root value handlers support bare-root values such as
--trace '.*' - required-value handlers may consume a first value token that begins with
- - literal
--is rejected as an unknown option; it is not treated as an option terminator
Demo Layout
demo/bootstrap/minimal import and parse smoke testdemo/sdk/{alpha,beta,gamma}reusable inline parser modulesdemo/exe/core/local app handlers plus the alpha inline parserdemo/exe/omega/combined alpha, beta, gamma, and local build parsers
Repository Layout
- Public Python package:
src/kcli/ - Unit tests:
tests/ - Integration demos:
demo/
The demos are part of the expected behavior contract and have subprocess-based coverage under demo/tests/.
Coding Agents
Read the workspace instructions first, then use the repo-local docs and tests as the implementation contract.