Application Programming Interfaces¶
The CFG format can be used through libraries with an API, which depends on the implementation language. The following sections describe the API exposed by a number of different implementations of functionality to work with CFG.
In all current implementations, there are two levels:
- A low level which parses CFG source to produce an abstract syntax tree (AST).
- A higher level which uses the parser to create higher-level configuration objects, which are what your programs will interact with in most cases.
Currently, only the higher level is documented, as it should be all that’s needed to work with CFG files.
Use the links below to look at the APIs for various languages. They are broadly similar for each of the implementations – Python, the JVM (using Kotlin), .NET, Go, Rust, D, JavaScript, Ruby, Elixir and Nim.
- The CFG API for Python
- Backwards-Incompatible Changes
- Modules
- Installation
- Getting Started with CFG in Python
- Loading a configuration
- Access elements with keys
- Access elements with paths
- Access to
datetime
objects - Access to other Python objects
- Access to environment variables
- Access to computed values
- Including one configuration inside another
- Avoiding unnecessary repetition
- A larger example - Django configuration
- Classes
- The CFG API for Kotlin / Java
- The CFG API for .NET
- The CFG API for Rust
- The CFG API for Go
- The CFG API for D
- The CFG API for JavaScript
- The CFG API for Ruby
- The CFG API for Elixir
- The CFG API for Nim
- The CFG API for Dart