Skip to content

yaml/go-yaml-cli

Repository files navigation

go-yaml-cli

A command line tool for the github.com/yaml/go-yaml library

Description

This repo creates a command line tool called go-yaml.

It read YAML from stdin and outputs it in many formats, including the internal states of go-yaml.

This program is extremely useful for understanding / debugging how go-yaml loads YAML documents.

You might want to use its output to report bugs for behaviors of go-yaml or its downstream consumers.

Installation

Run:

$ make install PREFIX=<prefix>

Where <prefix> is the directory that contains a bin subdirectory where the go-yaml binary will be installed: <prefix>/bin/go-yaml.

If you have GOROOT set in your environment, you could use:

$ make install PREFIX="$GOROOT"

Note: go install github.com/yaml/go-yaml-cli@latest doesn't work for this repo yet.

CLI Usage

This program reads YAML from stdin and prints output according to the options you give it (to stdout).

go-yaml --help describes the usage well:

$ go-yaml --help
go-yaml version 4.0.0.1

The 'go-yaml' tool shows how the go.yaml.in/yaml/v4 library handles YAML both
internally and externally. It is a tool for testing and debugging the library.

It reads YAML input text from stdin and writes results to stdout.

The go-yaml API has two different pairs of functions for reading and writing
YAML: Decode/Encode and Unmarshal/Marshal.

Decode and Encode are used by default. Use -u and -m for Unmarshal and Marshal.


Usage:
  go-yaml [options]

Options:
  -y, --yaml       YAML encoding output
  -Y, --YAML       YAML w/ style and comments preserved

  -j, --json       JSON compact output
  -J, --JSON       JSON pretty output

  -t, --token      Token output
  -T, --TOKEN      Token with line info

  -e, --event      Event output
  -E, --EVENT      Event with line info

  -n, --node       Node representation output

  -l, --long       Long (block) formatted output

  -u, --unmarshal  Use Unmarshal instead of Decode for YAML input
  -m, --marshal    Use Marshal instead of Encode for YAML output

  -h, --help       Show this help information
  --version        Show version information

Makefile Usage

$ make build
$ make test
$ make install PREFIX=<prefix>
$ make clean
$ make distclean

Using the Makefile requires no prerequisites. On first run, this will install all dependencies locally in this directory including a local installation of Go.

License

Copyright 2025 - Ingy döt Net

This project is licensed under the Apache License, Version 2.0.

See the LICENSE file for details.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published