Skip to content

Commit

Permalink
update readme to sync
Browse files Browse the repository at this point in the history
  • Loading branch information
semihbkgr committed Nov 5, 2024
1 parent 4e622e7 commit c9a787c
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 21 deletions.
69 changes: 54 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# yamldiff

yamldiff is a utility tool that applies a structural comparison on yaml files, making it easier to identify and understand the differences between them.
yamldiff is a utility tool for performing structural comparisons on YAML files, helping you easily identify and understand differences between them.

It basically compares the structural differences between two yaml files.
It focuses on highlighting structural variations between two YAML files.

![example](images/example.png)

Expand All @@ -14,24 +14,22 @@ $ go install github.com/semihbkgr/yamldiff@latest

Run with `help` flag to display a list of available options

``` bash
```bash
$ yamldiff --help

yamldiff is a tool for comparing the structural differences between two yaml files
structural comparison on two yaml files

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

Flags:
-c, --comment display comments in the output
-e, --exit returns non-zero exit status if there is a difference between yaml files
-h, --help help for yamldiff
-i, --ignore ignore indexes in array
-m, --metadata include metadata in the output (not work with silent flag)
-p, --plain uncolored output
-s, --silent print output in silent ignoring values
-v, --version version for yamldiff

-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
Expand All @@ -41,3 +39,44 @@ $ yamldiff --metadata examples/pod-v1.yaml examples/pod-v2.yaml
```
![example-metadata](images/example-metadata.png)
It can also be imported as a library in Go.
```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)
}
```
```out
~ name: Alice -> Bob
- city: New York
+ value: 990
~ items[1]: two -> three
```
13 changes: 7 additions & 6 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@ import (
)

var rootCmd = &cobra.Command{
Use: "yamldiff <file-left> <file-right>",
Short: "structural comparison of yaml files",
Args: cobra.ExactArgs(2),
SilenceUsage: false,
RunE: run,
Version: version(),
Use: "yamldiff [flags] <file-left> <file-right>",
Short: "structural comparison on two yaml files",
Args: cobra.ExactArgs(2),
SilenceUsage: false,
DisableFlagsInUseLine: true,
RunE: run,
Version: version(),
}

func Execute() {
Expand Down

0 comments on commit c9a787c

Please sign in to comment.