How-to guides
Recipes for one task each, for a reader who already knows what they want to do.
Each guide solves one task and assumes you have dmog installed, except the guides to the libraries, which start by adding one to a project. To learn dmog from the start, take the tutorials first. For every option a guide uses, see the reference.
Setting up #
Install dmog, in whichever runtime you already use.
Translating documents #
Write a document of one format in another: all of it or part of it, reshaped on the way, and documents that cannot be streamed.
- Translate a document to another formatWrite a file, or standard input, in another format, and save the result.
- Translate part of a documentPick one value out of a document with --path and write only that value.
- Name the key a document is written underChoose the key --key wraps a document under, for a format whose root must be an object.
- Translate a document that cannot be streamedUse --whole for a document with a repeated key or several YAML documents, which dmog cannot write as it reads.
- Reshape a document while translating itRun an alchemy program over the input with --with, and write what it returns in the target format.
- Convert a grammar between ABNF, EBNF, and GBNFWrite a grammar from one notation in another, and understand the refusals when a notation cannot say a rule.
- Limit how much dmog writesStop a translation or a program with --max-output-bytes once its output would pass a size you choose.
Running programs #
Check, format and explain an alchemy program, and run it over a document.
- Run a program over a documentRun an alchemy program over a JSON document with dmog run, and choose how a table it returns is written.
- Check and format a programFind the mistakes in an alchemy program before it runs, and print it in canonical or layout form.
- Find out what a program keeps in memoryRead the plan report dmog explain prints, to learn how a program reads its input and what it holds while it runs.
Scripting #
Use dmog from a script: read its failures and its exit statuses.
Using the libraries #
Call dmog from a program of your own, in TypeScript, Go, or Rust.
- Use the TypeScript libraryAdd @tabnas/dmog to a Node.js project, translate a string or a stream, run a program, read a failure, stop a run, and choose between the asynchronous and synchronous forms.
- Use the Go libraryAdd the dmog module to a Go program, translate a string or a stream, run a program, read a failure, set a limit, and stop a run with its context.
- Use the Rust libraryAdd tabnas-dmog to a Rust project, translate a string or a stream, run a program, read a failure, and stop a run that is under way.