# DSL The _`doit`-specific language_ provides some declarative shortcuts to techniques that usually require more complex Python or shell. ## `${}` Get Environment Variables > Get the value of an environment variable. Usually executed before any other parsers. > All config sources share the _same_ namespace.
```{mermaid} flowchart LR any-before --> dollar-leftbrace --> var-name --> rightbrace --> any-after any-before([any text]) dollar-leftbrace(["${"]) rightbrace(["}"]) var-name([a variable name]) any-after([any text]) ```
Environment variables are shared across all `doitoml` configuration files. ### Examples > TODO ## `:get` Get File Data > Read a piece of data from a path in a structured file: the result is usally cast to a > JSON string, if neccessary.
```{mermaid} flowchart LR get --> defaults --> parsers --> paths --> selectors get([:get]) subgraph defaults [0 or 1 default] default(["| value"]) end subgraph parsers [1 parser] direction LR json([::json]) toml([::toml]) yaml([::yaml]) end subgraph paths [1 path] path([::path]) end subgraph selectors [1+ selectors] selector([::string or int]) end ```
Use this to get data from a predictable location in a structured data file, such as a software package version. ### Examples ````{tab-set} ```{tab-item} pyproject.toml Get a version number. ~~~toml [project] version = "0.1.0" [tool.doitoml.env] PY_VERSION = ":get::toml::pyproject.toml::project::version" ~~~ ``` ```{tab-item} package.json Get a version number. ~~~json { "version": "0.1.0", "doitoml": { "env": { "JS_VERSION": ":get::json::package.json::version" } } } ~~~ ``` ```` ## `::` Reference a path or token > Get the value of any `paths` or `tokens`, either in the same `doitoml` configuration > file, or with a named prefix (including {mod}`fnmatch` wildcards).
```{mermaid} flowchart LR colon-colon --> prefixes --> token_or_path token_or_path -.-> path & tokens prefix & prefix-wildcard -.-> source-prefix colon-colon([::]) token_or_path([::token or path]) subgraph prefixes [0 or 1 prefix] prefix([::prefix]) prefix-wildcard(["::[fragment, ?, or *] ..."]) end subgraph doitoml ["doitoml configuration"] source-prefix("prefix = ...") subgraph paths [".paths"] path("some_path = [...]") end subgraph tokens [".tokens"] token("some_token = [...]") end end ```
### Examples > TODO ## `:glob` Find files
```{mermaid} flowchart LR glob & rglob --> roots --> matches --> excludes --> subs glob([:glob]) rglob([:rglob]) subgraph roots [1 root] root([::path/to/root]) end subgraph matches [1+ matches] match([::path/with/*]) end subgraph excludes [0+ excludes] exclude([::!a regex]) end subgraph subs [0+ substitutions] sub([::/s/]) sub-find([::a regex]) sub-replace([::replacement]) sub --> sub-find --> sub-replace end ```
### Examples > TODO