yamlfmt

package module
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 19, 2023 License: BSD-3-Clause Imports: 5 Imported by: 4

README

yamlfmt

Go build

based on gofmt, yamlfmt formats yaml files into a canonical format

  • lists are not indented
  • maps have sorted keys
  • indent is 2 spaces
  • documents always have separators ---
$ yamlfmt --help
formats yaml files with 2 space indent, sorted dicts and non-indented lists
usage: yamlfmt [flags] [path ...]
  -d    display diffs instead of rewriting files
  -f    exit non zero if changes detected
  -l    list files whose formatting differs from yamlfmt's
  -s    sort maps & sequences, WARNING: This may break anchors & aliases
  -w    write result to (source) file instead of stdout

Without an explicit path, it processes the standard input. Given a file, it operates on that file; given a directory, it operates on all .yaml and .yml files in that directory, recursively.

By default, yamlfmt prints the reformatted sources to standard output.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Format

func Format(r io.Reader, sort bool) ([]byte, error)

Format reads in a yaml document and outputs the yaml in a standard format. If sort is true than dictionary keys are sorted lexicographically Indents are set to 2 Lists are not indented

Types

This section is empty.

Directories

Path Synopsis
cmd
yamlfmt command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL