yamldiff

command module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2024 License: MIT Imports: 1 Imported by: 0

README

yamldiff

yamldiff is a utility tool for performing structural comparisons on YAML files, helping you easily identify and understand differences between them.

It focuses on highlighting structural variations between two YAML files.

example

Installation

$ go install github.com/semihbkgr/yamldiff@latest

Run with help flag to display a list of available options

$ yamldiff --help
structural comparison on two yaml files

Usage:
  yamldiff [flags] <file-left> <file-right>

Flags:
  -c, --comment     Include comments in the output when available.
  -e, --exit        Exit with a non-zero status code if differences are found between yaml files.
  -h, --help        help for yamldiff
  -m, --metadata    Include additional metadata in the output (not applicable with the silent flag).
  -p, --plain       Output without any color formatting.
  -s, --silent      Suppress output of values, showing only differences.
  -u, --unordered   Ignore the order of items in arrays during comparison.
  -v, --version     version for yamldiff

Example

$ yamldiff --metadata examples/pod-v1.yaml examples/pod-v2.yaml

example-metadata

It can also be imported as a library in Go.

func main() {
  left := []byte(`
name: Alice
city:  New York
items:
  - one
  - two
`)

  right := []byte(`
name: Bob
value: 990
items:
  - one
  - three
`)

  diffs, err := compare.Compare(left, right, false, compare.DefaultDiffOptions)
  if err != nil {
    panic(err)
  }

  output := diffs.Format(compare.FormatOptions{
    Plain:    true,
    Silent:   false,
    Metadata: false,
  })
  fmt.Println(output)
}
~ name: Alice -> Bob
- city: New York
+ value: 990
~ items[1]: two -> three

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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