Metadata-Version: 2.4
Name: kaiv
Version: 0.1.0
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Rust
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
License-File: LICENSE-APACHE
License-File: LICENSE-MIT
Summary: Python bindings for kaiv, a Kv Format Swiss-Army knife
Keywords: kv,kvformat,cli,env,config
Home-Page: https://kvformat.org/
Author: Bojan Đuričković
License: MIT OR Apache-2.0
Requires-Python: >=3.8
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
Project-URL: Homepage, https://kvformat.org/
Project-URL: Repository, https://github.com/kvformat/kaiv-py
Project-URL: Upstream Rust crate, https://github.com/kvformat/kaiv-rs

# kaiv — Kv Format Swiss-Army knife

Python bindings for [kaiv-rs](https://github.com/kvformat/kaiv-rs), the
[Kv Format](https://kvformat.org/) Swiss-Army knife CLI tool.  
Install the `kaiv` CLI and its Python API in one step:

```
pip install kaiv
```

## CLI usage

```
# Print a value by key
kaiv get APP_NAME config.kv

# Validate a KV file
kaiv check config.kv

# Re-output in canonical form (sorted keys, no comments)
kaiv fmt config.kv

# Export to JSON
kaiv export json config.kv

# Import from JSON
kaiv import json config.json
```

Pass `-` or omit the file argument to read from stdin.

## Python API

```python
import kaiv

# Get a value by key (returns None if not found)
value = kaiv.get("APP_NAME", "APP_NAME=My App\nDEBUG=true\n")
# => "My App"

# Validate KV input (returns a list of error strings, empty if valid)
errors = kaiv.check("APP_NAME=My App\nDEBUG=true\n")
# => []

# Canonical form (sorted keys, no comments/blanks)
canonical = kaiv.fmt("DEBUG=true\nAPP_NAME=My App\n")
# => "APP_NAME=My App\nDEBUG=true\n"

# Export KV to JSON
json_str = kaiv.export_json("APP_NAME=My App\nDEBUG=true\n")
# => '{"APP_NAME":"My App","DEBUG":"true"}'

# Import JSON to KV
kv_str = kaiv.import_json('{"APP_NAME":"My App","DEBUG":"true"}')
# => "APP_NAME=My App\nDEBUG=true\n"
```

All functions accept a string of KV content (not a file path) and raise
`ValueError` on invalid input.

## Development

Prerequisites: Rust toolchain, Python ≥ 3.8, [maturin](https://maturin.rs/)

```bash
pip install maturin
# Build and install into the current virtualenv for development
maturin develop
# Build a release wheel
maturin build --release
# Publish to PyPI
maturin publish
```

