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.1.1.tar.gz (39.8 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.1.1-py3-none-win_amd64.whl (759.1 kB view details)

Uploaded Python 3Windows x86-64

cscm-0.1.1-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (970.7 kB view details)

Uploaded Python 3manylinux: glibc 2.17+ x86-64

cscm-0.1.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (948.3 kB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARM64

cscm-0.1.1-py3-none-macosx_11_0_arm64.whl (849.8 kB view details)

Uploaded Python 3macOS 11.0+ ARM64

cscm-0.1.1-py3-none-macosx_10_12_x86_64.whl (893.3 kB view details)

Uploaded Python 3macOS 10.12+ x86-64

File details

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

File metadata

  • Download URL: cscm-0.1.1.tar.gz
  • Upload date:
  • Size: 39.8 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.1.1.tar.gz
Algorithm Hash digest
SHA256 9a1e5e049512eabbaa7f6fe20e721c1bde9462f8855f533577aad465b68eb3f5
MD5 d5c23cb12be56e24b428f23032aa06ba
BLAKE2b-256 310e69b463e28953654b498b0439918b8d4dba3dec4ade9dc32ebffc0aa46344

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cscm-0.1.1-py3-none-win_amd64.whl
  • Upload date:
  • Size: 759.1 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.1.1-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 84d097130a441beffc27c394287eddd02d5e18a123eb18350824104a4a8270aa
MD5 ba5a9bc456c083c45cdfc78652c8ff4e
BLAKE2b-256 2c52d7c63177e85a9ddd67f60a92c2b6f6537ab3dc71852c2e0d1d58b9ffc272

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cscm-0.1.1-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
  • Upload date:
  • Size: 970.7 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.1.1-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 edb45753216a30d9e8a56444baa2717d179c3d3b242dfa8b81231d102186db02
MD5 b21e9f49ec66a8e607545dbb839b0d5c
BLAKE2b-256 a3f631de713942c0f3a2971586d7c59f5dc7d943db9e4260a7a65fb2666b2f92

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cscm-0.1.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
  • Upload date:
  • Size: 948.3 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.1.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 c7891641c3fe6c5f9afbd1897a75b93761bd6871e7380ade5f02db50038e86a9
MD5 60601e3b0e017fa669755fd0bef7be11
BLAKE2b-256 8116f41f74cf85dc8c5ff346bd4cb1ba6e78ce7d43522b48e1eb6953e1537e05

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cscm-0.1.1-py3-none-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 849.8 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.1.1-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6ff82c50c9767b1c63ca165a031a5934345abea361dd65802dd264555e09ee09
MD5 b19147744cfee3b403e1261ffa853333
BLAKE2b-256 745e0e7c8ad4f3df1d7be33f9dad2e97b02fd374092e9fa2718eccc34f5d557c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cscm-0.1.1-py3-none-macosx_10_12_x86_64.whl
  • Upload date:
  • Size: 893.3 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.1.1-py3-none-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 f6ee123fb4be4321b07c8a3b0354158f62b28081291ec24896801a6a25f7a6bb
MD5 3fd169a23e66aa6b4818da33137edc4d
BLAKE2b-256 72cccd8d9ab0133fa6c7471985f9e03c2c3f79f7ee9a1da1809c18b02d650984

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