Skip to main content

Compiler for the cscm configuration-schema DSL

Project description

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

cargo install cscm
pip install cscm

Or download a prebuilt binary from the GitHub Releases page (Linux/macOS/Windows, x86_64 + aarch64).

Usage

cscm schema.cscm --lang python -o config.py
  • --lang and -o are each independently optional: --lang is inferred from -o's extension (.pypython) 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:

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:

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

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 or MIT license at your option.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cscm-0.2.0.tar.gz (49.4 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

cscm-0.2.0-py3-none-win_amd64.whl (765.9 kB view details)

Uploaded Python 3Windows x86-64

cscm-0.2.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (979.0 kB view details)

Uploaded Python 3manylinux: glibc 2.17+ x86-64

cscm-0.2.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (955.7 kB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARM64

cscm-0.2.0-py3-none-macosx_11_0_arm64.whl (858.4 kB view details)

Uploaded Python 3macOS 11.0+ ARM64

cscm-0.2.0-py3-none-macosx_10_12_x86_64.whl (901.9 kB view details)

Uploaded Python 3macOS 10.12+ x86-64

File details

Details for the file cscm-0.2.0.tar.gz.

File metadata

  • Download URL: cscm-0.2.0.tar.gz
  • Upload date:
  • Size: 49.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.32 {"installer":{"name":"uv","version":"0.11.32","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for cscm-0.2.0.tar.gz
Algorithm Hash digest
SHA256 e1b0383a64c6275c5ee7d79106964c94e56a2216f3cd5c03eb723df6535f5b8b
MD5 c9ce621236261839664a4d30982bd3a5
BLAKE2b-256 018d7f7b758738a9b8bcceebf12c78c1bd87bdfbfd8f22befe35ca7f1aabaa19

See more details on using hashes here.

File details

Details for the file cscm-0.2.0-py3-none-win_amd64.whl.

File metadata

  • Download URL: cscm-0.2.0-py3-none-win_amd64.whl
  • Upload date:
  • Size: 765.9 kB
  • Tags: Python 3, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.32 {"installer":{"name":"uv","version":"0.11.32","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for cscm-0.2.0-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 0b4c68ba12bbc7ddb837231fa47db8f3e8cf880b8e62bdc7821ddb5ed8306b94
MD5 dd5a76f25a3aecaeab1e74d78ea8a047
BLAKE2b-256 29036dbfe085c03ffdb62234fc27486b739e6b77fdc317e9f64566604c015796

See more details on using hashes here.

File details

Details for the file cscm-0.2.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

  • Download URL: cscm-0.2.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
  • Upload date:
  • Size: 979.0 kB
  • Tags: Python 3, manylinux: glibc 2.17+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.32 {"installer":{"name":"uv","version":"0.11.32","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for cscm-0.2.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1be1a30f706dfc72bffb5362f4954f7c6368c6677292e3d8962b6f447440774d
MD5 e3b72038de90299d81affbce17594615
BLAKE2b-256 ee5f326713082fd1094ef304823b887da6c8adb4915655a76b64da14db22711c

See more details on using hashes here.

File details

Details for the file cscm-0.2.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

  • Download URL: cscm-0.2.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
  • Upload date:
  • Size: 955.7 kB
  • Tags: Python 3, manylinux: glibc 2.17+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.32 {"installer":{"name":"uv","version":"0.11.32","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for cscm-0.2.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 438e16c21a6aa05eff5617a5fe42343a61f7eec767f749f5b4c30db566cd30de
MD5 7f7d65382587df0377d9566249d49f59
BLAKE2b-256 c25179d4ac13c4078c04531f2a35a3d59863b64bd2d6dfc32438733952c4d284

See more details on using hashes here.

File details

Details for the file cscm-0.2.0-py3-none-macosx_11_0_arm64.whl.

File metadata

  • Download URL: cscm-0.2.0-py3-none-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 858.4 kB
  • Tags: Python 3, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.32 {"installer":{"name":"uv","version":"0.11.32","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for cscm-0.2.0-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5afb8f096374e5f0f6b7819fb3a7078be89da2c99242be89295900bf9bbfa6a1
MD5 bc38d63b546034f9c5a63b69768771b1
BLAKE2b-256 4e758aed9fdf15e7a09f43776ec55dc6edaa0d66629a7a8ee090e4642db9cad4

See more details on using hashes here.

File details

Details for the file cscm-0.2.0-py3-none-macosx_10_12_x86_64.whl.

File metadata

  • Download URL: cscm-0.2.0-py3-none-macosx_10_12_x86_64.whl
  • Upload date:
  • Size: 901.9 kB
  • Tags: Python 3, macOS 10.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.32 {"installer":{"name":"uv","version":"0.11.32","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for cscm-0.2.0-py3-none-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 215ea46609cb3e85ca24594e96eb3dbdaf92c2c3e7e98af37ddf03757a7fa549
MD5 220b10bb427abe52e1688954d4fa9f41
BLAKE2b-256 98a1ea2add6d875409d311b99c3c0e68b45afefe95ef2499b9eb7c24466724a4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page