vinyl

package module
v0.0.0-...-625af1c Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2022 License: BSD-3-Clause Imports: 4 Imported by: 0

README

VINYL Inscribes Nettlesome YAML Legibly

VINYL formats yaml files into a canonical format retaining comments and setting the indentation by default to two spaces, including for sequences, e.g.:

# List of recipes
recipies:
  # todo
  - pizza: {}
  # todo
  - lasagna: {}
  - barley soup:
      ingredients:
        - barley
        - onions
        - beef
      serves: 4

It uses code from gofmt and go-yaml does the heavy lifting of parsing the yaml and formatting the output

Usage

$ ./vinyl --help
usage: vinyl [flags] [path ...]
  -cpuprofile string
        write cpu profile to this file
  -d    display diffs instead of rewriting files
  -i uint
        number of spaces to indent (default 2)
  -l    list files whose formatting differs from vinyl's
  -m    don't error on duplicate keys in mappings
  -w    write result to (source) file instead of stdout

Without an explicit path, it processes from 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, vinyl prints the reformatted sources to standard output.

Credits

  • yamlfmt: VINYL is a fork of yamlfmt
  • gofmt: Code to format all files and handle errors
  • go-yaml YAML parser

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Format

func Format(filename string, r io.Reader, opts FormatOpts) ([]byte, error)

Format reads in a yaml document and outputs the yaml in a standard format. Indents are set to 2 Lists are not indented

Types

type FormatOpts

type FormatOpts struct {
	IndentNum        uint
	IgnoreMapKeyDups bool
}

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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