lintel-config 0.0.4

Configuration types and loader for Lintel (lintel.toml)
Documentation
# lintel-config

[![Crates.io](https://img.shields.io/crates/v/lintel-config.svg)](https://crates.io/crates/lintel-config)
[![docs.rs](https://docs.rs/lintel-config/badge.svg)](https://docs.rs/lintel-config)
[![CI](https://github.com/lintel-rs/lintel/actions/workflows/ci.yml/badge.svg)](https://github.com/lintel-rs/lintel/actions/workflows/ci.yml)
[![License](https://img.shields.io/crates/l/lintel-config.svg)](https://github.com/lintel-rs/lintel/blob/master/LICENSE)

Configuration types and loader for [Lintel](https://github.com/lintel-rs/lintel). Defines the `lintel.toml` schema, parses config files, and provides utilities for schema URI rewriting and path resolution.

## Features

- **Config types**`Config` and `Override` structs with serde deserialization and JSON Schema generation via [schemars]https://crates.io/crates/schemars
- **Hierarchical loading** — walks up the directory tree merging `lintel.toml` files until `root = true`
- **URI rewriting** — prefix-based rewrite rules with longest-prefix-wins semantics
- **`//` path resolution** — resolve `//`-prefixed paths relative to the config directory
- **Schema generation** — generates the JSON Schema for `lintel.toml` (used at build time by `lintel-check` and as a standalone binary)

## Usage

```rust
use lintel_config::{find_and_load, apply_rewrites, resolve_double_slash};

// Load config by walking up from a directory
let config = find_and_load(std::path::Path::new("."))
    .unwrap()
    .unwrap_or_default();

// Check for custom schema mappings
if let Some(url) = config.find_schema_mapping("src/config.json", "config.json") {
    println!("Schema: {url}");
}

// Apply rewrite rules and resolve // paths
let uri = apply_rewrites("http://localhost:8000/schema.json", &config.rewrite);
let uri = resolve_double_slash(&uri, std::path::Path::new("/project"));
drop(uri);
```

### Standalone binary

```sh
cargo run -p lintel-config
```

Prints the JSON Schema for `lintel.toml` to stdout.

## License

Apache-2.0