yamlctl

module
v0.0.0-...-4a0a1b7 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2022 License: Apache-2.0

README

yamlctl

An experimental tool to modify YAMLs without losing (most of) comment lines.

yamlctl edit --set $.foo.bar=baz <input.yaml >output.yaml

Inline comments and some whitespaces are not preserved.

Install

go install github.com/AkihiroSuda/yamlctl/cmd/yamlctl@master

Usage

yamlctl editable
yamlctl editable input.yaml

Prints true if the YAML is well formatted for yamlctl edit.

Misformatted YAMLs are not safely editable, but can be edited forcibly with yamlctl edit --force.

yamlctl edit
yamlctl edit --set $.foo.bar=baz <input.yaml >output.yaml

Set -w to write back the result to input.yaml directly:

yamlctl edit -w --set $.foo.bar=baz input.yaml

Set --bak to create backup files like input.yaml.bak.0, input.yaml.bak.1, ...

Set --force to edit a misformatted YAML forcibly.

yamlctl query
yamlctl query $.foo.bar input.yaml
yamlctl yaml2json
yamlctl yaml2json input.yaml

Go library (yamlutil)

https://pkg.go.dev/github.com/AkihiroSuda/yamlctl/pkg/yamlutil

See the unit tests for the usage.

Similar projects

Directories

Path Synopsis
cmd
pkg

Jump to

Keyboard shortcuts

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