Small Python CLI library
Project description
Kliamka
A small Python CLI library that provides Pydantic-based argument parser with type safety.
Features
- Type-safe CLI arguments with Pydantic validation
- Decorator-based design for clean, readable code
- Automatic argument parsing from class definitions
- Modern Python 3.11+ with full type hints
Installation
# Install via pip
pip install kliamka
# Install from source
git clone https://github.com/hotsyk/kliamka.git
cd kliamka
make install
# Or install in development mode
pip install -e .
Quick Start
from kliamka import KliamkaArg, KliamkaArgClass, kliamka_cli
class MyArgs(KliamkaArgClass):
"""My CLI application arguments."""
verbose: bool | None = KliamkaArg("--verbose", "Enable verbose output")
count: int | None = KliamkaArg("--count", "Number of iterations", default=1)
@kliamka_cli(MyArgs)
def main(args: MyArgs) -> None:
"""Main application logic."""
if args.verbose:
print("Verbose mode enabled")
for i in range(args.count or 1):
print(f"Iteration {i + 1}")
if __name__ == "__main__":
main()
Run your CLI:
python my_app.py --verbose --count 3
API Reference
Core Components
KliamkaArg
Descriptor for defining CLI arguments with automatic type inference.
class KliamkaArg:
def __init__(self, flag: str, help_text: str = "", default: Any = None)
KliamkaArgClass
Base class for CLI argument definitions using Pydantic models.
class MyArgs(KliamkaArgClass):
debug: bool | None = KliamkaArg("--debug", "Enable debug mode")
config: str | None = KliamkaArg("--config", "Configuration file path")
@kliamka_cli
Decorator that automatically parses CLI arguments and injects them as the first parameter.
@kliamka_cli(MyArgs)
def main(args: MyArgs) -> None:
# args is automatically populated from command line
pass
Examples
See the examples/ directory for more comprehensive usage examples:
examples/basic_usage.py- Basic CLI argument handlingexamples/enums.py- Handling of enumerated types
Development
Requirements
- Python 3.11+
- Pydantic 2.0+
Setup
# Clone and setup
git clone https://github.com/hotsyk/kliamka.git
cd kliamka
make install
# Run tests
make test
# Lint and type check
make lint
# Run example
python examples/basic_usage.py --help
Versions
See VERSIONS.md for detailed version history and changelog.
Available Make Commands
make install- Install package in development modemake run- Run the CLI applicationmake test- Run tests with pytestmake lint- Run type checking and lintingmake format- Format code with ruffmake clean- Clean build artifacts
Documentation
- Examples - Usage examples and demos
Contributing
- Fork the repository
- Create a feature branch
- Make your changes with tests
- Run
make lintandmake test - Submit a pull request
License
MIT-NORUS License - see LICENSE file for details.
Author
Volodymyr Hotsyk - https://github.com/hotsyk
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file kliamka-0.3.0.tar.gz.
File metadata
- Download URL: kliamka-0.3.0.tar.gz
- Upload date:
- Size: 11.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1a80e5cfc24edd6ce129c6951cd3c87bf979ae58fa11cc601b468514066d6fa1
|
|
| MD5 |
d00b108262d4a048cf0a84e97c0dac6f
|
|
| BLAKE2b-256 |
160cbc71609f1afc4bd1409485602d97b00ebc498d2499e2be68b0ea3c4f4f90
|
Provenance
The following attestation bundles were made for kliamka-0.3.0.tar.gz:
Publisher:
publish.yml on hotsyk/kliamka
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
kliamka-0.3.0.tar.gz -
Subject digest:
1a80e5cfc24edd6ce129c6951cd3c87bf979ae58fa11cc601b468514066d6fa1 - Sigstore transparency entry: 771820168
- Sigstore integration time:
-
Permalink:
hotsyk/kliamka@3b793b8f5607b23bc58c41aef031cda7458a35ba -
Branch / Tag:
refs/heads/main - Owner: https://github.com/hotsyk
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@3b793b8f5607b23bc58c41aef031cda7458a35ba -
Trigger Event:
workflow_run
-
Statement type:
File details
Details for the file kliamka-0.3.0-py3-none-any.whl.
File metadata
- Download URL: kliamka-0.3.0-py3-none-any.whl
- Upload date:
- Size: 8.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4bce627d0223d3b0b7f7e5e41d9617590368546076d8316ac9c465a3f52ccd86
|
|
| MD5 |
63133acb9b879737bd523378013d8b41
|
|
| BLAKE2b-256 |
08b3e41a59a9a023e7aedf8830fc9a41ddbe83356b5c417bdd6d9cb93eade236
|
Provenance
The following attestation bundles were made for kliamka-0.3.0-py3-none-any.whl:
Publisher:
publish.yml on hotsyk/kliamka
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
kliamka-0.3.0-py3-none-any.whl -
Subject digest:
4bce627d0223d3b0b7f7e5e41d9617590368546076d8316ac9c465a3f52ccd86 - Sigstore transparency entry: 771820172
- Sigstore integration time:
-
Permalink:
hotsyk/kliamka@3b793b8f5607b23bc58c41aef031cda7458a35ba -
Branch / Tag:
refs/heads/main - Owner: https://github.com/hotsyk
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@3b793b8f5607b23bc58c41aef031cda7458a35ba -
Trigger Event:
workflow_run
-
Statement type: