Skip to content

YAMLStar CLI

The yaml command loads YAML and prints JSON by default. It can also emit YAML with -Y.

Examples

Read from standard input and print compact JSON:

printf 'name: YAMLStar\n' | yaml

Load a file:

yaml config.yaml

Pretty-print JSON:

yaml -J config.yaml

Emit YAML:

yaml -Y config.yaml

Load every document in a YAML stream:

yaml -s stream.yaml

Emit every document in a YAML stream:

yaml -Y -s stream.yaml

Evaluate a YAML string directly:

yaml -e 'a: 1'

Write output to a file:

yaml config.yaml -o config.json

Options

Usage: yaml [options] [file]

Default: Read stdin, output compact JSON

Options:
  -f, --file FILE          Input file (or use positional arg)
  -e, --eval YAML          Evaluate YAML string
  -J, --json               Output pretty JSON
  -Y, --yaml               Output YAML
  -o, --output FILE        Output file
  -s, --stream             Output all documents
  -d, --debug              Debug all stages
  -D, --debug-stage STAGE  Debug specific stage: parse, compose, resolve,
                           construct
  -S, --stack-trace        Show full stack traces
  -v, --version            Print version
  -h, --help               Print help

-Y emits YAML using YAMLStar's dump stack:

native value
  -> representer/represent
  -> desolver/desolve
  -> serializer/serialize
  -> emitter/emit
  -> YAML string

With -s, it emits all input documents as a YAML stream with document separators.

Debugging

The CLI can show each loader stage. This is useful when developing the parser or investigating how a YAML document is interpreted:

yaml -D parse config.yaml
yaml -D compose config.yaml
yaml -D resolve config.yaml
yaml -D construct config.yaml

Use -d to run every debug stage.