Metadata-Version: 2.4
Name: cscm
Version: 0.2.0
License-File: LICENSE-MIT
License-File: LICENSE-APACHE
Summary: Compiler for the cscm configuration-schema DSL
Home-Page: https://github.com/tamakidevelop606/cscm
License-Expression: MIT OR Apache-2.0
Requires-Python: >=3.9
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
Project-URL: Homepage, https://github.com/tamakidevelop606/cscm
Project-URL: Repository, https://github.com/tamakidevelop606/cscm

# cscm

`cscm` is a compiler/toolchain for a small configuration-schema definition language. A `.cscm` file is
the single source of truth for a config schema; `cscm` generates model classes in a target language
(currently Python) that load, save, and validate real config files (JSON/YAML) against that schema.

```
server:
    host: String = "127.0.0.1"
    port: Int(min=1, max=65535) = 8080
    tls:
        enabled: Bool = false
```

## Install

```sh
cargo install cscm
```

```sh
pip install cscm
```

Or download a prebuilt binary from the [GitHub Releases page](https://github.com/tamakidevelop606/cscm/releases)
(Linux/macOS/Windows, x86_64 + aarch64).

## Usage

```sh
cscm schema.cscm --lang python -o config.py
```

- `--lang` and `-o` are each independently optional: `--lang` is inferred from `-o`'s extension
  (`.py` → `python`) if omitted; if both are omitted it's an error. If `-o` is omitted, generated code is
  written to stdout instead of a file.

The generated Python module is a plain `dataclass`-based API:

```python
from config import Config

cfg = Config.load("config.yaml")   # detects JSON vs YAML from the extension; validates on load
cfg.server.port                    # typed, validated access
cfg.save("config.yaml")
```

Generated code depends on a small shared runtime package at load/save time:

```sh
pip install cscm-runtime
```

## Language

- Indentation-based nesting (spaces only, no tabs).
- `#` line comments.
- Types: `Bool`, `Int`, `Float`, `String`, `List<T>`, `Map<T>` (`T` a scalar type; `Map` keys are always
  `String`). Nested indented blocks are the only way to express structure.
- Constraints as call-like arguments on the type: `Int(min=1, max=65535)`, `String(max=64)`,
  `String(pattern="[a-z]+")`.
- `Type?` makes a field's *value* nullable; `= default` makes the field optional to *omit* from the config
  file. The two are independent — see `CLAUDE.md` for the full grammar and all four combinations.

See `sample/web.cscm` for a larger example covering every type/constraint combination.

## Development

```sh
cargo build
cargo test
cargo run -- sample/web.cscm -o /tmp/config.py
```

See `CLAUDE.md` for full architecture notes, the generator's semantic-check rules, and current
distribution/publishing status.

## License

Licensed under either of [Apache License, Version 2.0](LICENSE-APACHE) or [MIT license](LICENSE-MIT) at
your option.

