Updated the list of supported platforms in the GitHub Actions
Docker release workflow to include linux/s390x.
Signed-off-by: Ashok Pariya <ashok.pariya@ibm.com>
With docker-hub starting to introduce a much stricter limit on anonymous
pulls, it makes sense to also host the image in ghcr.io as well,
allowing users flexibility in where they pull the docker images from.
Also with the github action it makes more sense hosting the docker image
on github infrastructure.
I've introduced a github action for logging into registries as well.
Problem: When --split-exp is used and produces filenames with slashes in
them, the target directories must already exist otherwise yq fails.
Fix/feature: Create the necessary directories with os.MkdirAll().
The permissions 0750 were chosen to satisfy the vulnerability checker.
Solves
```
❯ make test
Cannot connect to Podman. Please verify your connection to the Linux system using `podman system connection list`, or try `podman machine init` and `podman machine start` to manage a new Linux VM Error: unable to connect to Podman socket: failed to read identity "/Users/tiger/.local/share/containers/podman/machine/machine": open /Users/tiger/.local/share/containers/podman/machine/machine: no such file or directory /opt/homebrew/bin/docker run --rm -e LDFLAGS=" -X main.GitCommit=bbdd974+CHANGES -X main.GitDescribe=v4 -w -s" -e GITHUB_TOKEN="" -v /Users/tiger/git/yq-k8s/vendor:/go/src -v /Users/tiger/git/yq-k8s:/yq/src/github.com/mikefarah/yq -w /yq/src/github.com/mikefarah/yq yq_dev go mod vendor
Error: podman-machine-default: VM already exists
```
Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com>
* build: use goreleaser to cross-compile binaries for all platforms and archs
The main motivation behind it is because "gox" is unmaintained and archived
and it does not support "linux/riscv64" as a target.
Right now, goreleaser is only building the binaries, and I've tried to replicate
the exact same way the old script does.
In the future, if so desired, goreleaser could be used to further automate the
build and release pipeline by creating the release in GitHub.
* build: create binaries and OCI image for linux/riscv64
* convert file ext to lowercase for format detection
To ensure proper file format detection with case-insensitive file
systems.
* use filepath.Ext for more reliable file ext detection
especially for paths like index.js/foo
* add a test for file ext based format detection
This commit adds the --properties-separator option, which lets users
specify the separator used between keys and values in the properties
output format. This is done by adjusting the value of
github.com/magiconair/properties#Properties.WriteSeparator at encode
time.
Some refactoring of the properties encoder unit tests was done to make
it easier to write unit tests that include different separator values.
Fixes: #1864
Signed-off-by: Ryan Drew <ryan.drew@isovalent.com>
When the shell executing yq has no open stdin, os.Stdin.Stat() return nil and yq fails to continue. This commit fixes a missing verification on the result of os.Stdin.Stat() in the utils.processStdInArgs function and adds an acceptance test to cover this scenario in the future. This bug affects yq since version 4.26.1.
* encoder_lua: Handle explicitly positive infinity
* encoder_lua: Fix inclusion of pre-/suffix when prettyPrinted
It seems certain operations like --prettyPrint or subset selections does
not produce a DocumentNode, which is where the lua pre- and suffix was
printed, causing those to be omitted.
* encoder_lua: Improve Tag handling robustness
Using the method call seems more reliable in case the input parser
forgets to set the tag.
- Add missing package manager (scoop)
- Improve winget installationn example & add link to reference documentation
- Add link to missing reference documentation for chocolatey
* Implement basic Lua output support
Ref #1700
Basic but working serialization to Lua tables.
* Escape larger set of characters in Lua output
Started with a minimum of replacements, this should be more complete,
tho not all substitutions are strictly required in Lua.
* Print simple keys unquoted in Lua output
String keys that satisfy the requirements for variable names can be used
as keys without quotes in tables.
* Quote Lua keywords in table keys
Keywords are not valid as unquoted keys, thus must be quoted
* Make output of unquoted Lua table keys optional
Generally safer and simpler to not do it.
* Hook up settings for Lua output
* Allow special characters in Lua prefix and suffix
--lua-suffix='});^M' didn't work, so taking this approach instead
* Panic on unhandled YAML Kind in Lua encoder
* Handle YAML case varied booleans in Lua encoder
* Handle special-case numbers in Lua encoder
* Reject unhandled scalar Tags in Lua encoder
* Add note about how Lua nil is unsuitable as table key
Could add some context tracking in the future to allow rejecting nil in
a table key context.
* Return error instead of panic in Lua encoder
* Add initial test for Lua encoder
Boilerplate mostly copied from toml_test.go
* Additional Lua output tests
* Generate Lua encoder documentation
Mostly just for the boilerplate
* Convert octal for Lua output
Lua doesn't have the 0oNNN syntax for octal integers, only decimal and
hexadecimal, hence those can be passed trough as is while octal needs
special treatment.
* Implement indentation in in Lua output
* Respect string Style in Lua encoder
Lua has 'single', "double" and [[ long ]] strings.
* Expand Lua examples
* Output line comments in Lua output
* Implement Lua globals output mode
* fix typo in a comment
* implement shell output format
* fix a typo
* add two test cases, have source uses ascii only
* add integration tests and documentation
* add fixes after code revieew
This is to ensure solid parsing of complex data (with any binary
content except NUL chars) by separating the `yq` root collection
member's output with NUL char. As a safe-guard, an error will be cast
if trying to use NUL character with content that contains itself NUL
characters inside.
Allow snap users to process YAML documents under /media or /mnt paths after connecting to the `removable-media` snapd slot:
```
sudo snap connect yq :removable-media
```
Fixes#1618.
* Remove extra backtick
* Reword explanation of update
* Reword explanation of relative update
* Change "remaple" to "remain"
* Change "clovver" to "clobber"
* Reword explanation of update for comment operators
* Reword explanation of relative update for comment operators
* Change "array" to "expression"
* Change "the golangs" to "Golang's"
* Change "golangs" to "Golang's"
* Change "can durations" to "can add durations"
* Change "array scalars" to "arrays"
* Change "beit" to "be it"
* Fix typo in `eval` tip
* Fix typo in header for `has` operation
* Add space before pipe in `line` operator example
* Fix typos in explanation of deep array merges
* Change "is now used" to "is now used."
* Change "object," to "object."
* Changes "indexes" to "indices"
* Remove extraneous copied text from `..` article
* Reword explanation of `...` operator
* Change "your are" to "you are"
* Add link to `string` operator docs in `select` article
* Change "is a" to "parameter specifies" in `string` operators article
* Change "new line" to "newline"
* Change "golang regex" to "Golang's regex"
* Change "golang" to "Golang"
* Add period
* Remove comma in `subtract` article
* Remove duplicate number subtraction example
* Remove comma in `traverse` operator article
* Clarify use of brackets when `read`ing with special characters
* detect inputFormat from filename
* refactor and extract func InputFormatFromFilename
* detect inputFormat only when file is provided
* add test for automatic input format detection
* Refactor ordered_map into separate files
Separate json and xml, from the regular yaml.
Makes it possible to compile, without those...
* Refactor encoder and decoder creation
Use more consistent parameters vs globals
Return errors instead of calling panic()
* Allow build without json and xml support
* Build constraint not working for non linux
* Go Build Constraint: Fix Non-Linux Filename (#1494)
Correct the filename pkg/yqlib/chown_not_linux.go to escape the
default OS detection in filename format `*_GOOS[_test].go`.
Add an extra word after `linux` to resolve the issue.
pkg/yqlib/chown_not_linux_os.go
Signed-off-by: Bhargav Ravuri <vaguecoder0to.n@gmail.com>
Signed-off-by: Bhargav Ravuri <vaguecoder0to.n@gmail.com>
Signed-off-by: Bhargav Ravuri <vaguecoder0to.n@gmail.com>
Co-authored-by: Bhargav Ravuri <saibhargavravuri@gmail.com>
1. Escaping behavior changed as a result of set-output deprecation.
- Otherwise you'll encounter breaking changes for example "appVersion: "1.0.0"%0Aapplica..."
where %0A is escaped newline \n but shouldn't be escaped.
2. Delimeter is required for multiline strings.
- See here: https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#multiline-strings
- Delimeter must be random. UUID is a solid choice.
I verified that /proc/sys/kernel/random/uuid does indeed exist on the yq image.
* adding support for --wrapScalar=false in properties encoder
* altering encoder and decoder tests somewhat
* adding .idea
* Revert "altering encoder and decoder tests somewhat"
This reverts commit e3655130e2.
* adding test scenario for encoding with wrapped scalars
4ec533b introduced a bug which causes the 'hidden' cli parameter
`__complete` to be ignored.
Add a check for this parameter, so that it can pass to `cobra`
Signed-off-by: Tom Whitwell <tom@whi.tw>
* Decoder Properties
* Added properties round trip test
* Fixed property decode for github actions
* Refactored XML test to use common functions
* Switched formatScenario parameter order for more readablity
* refactor: move from io/ioutil to io and os packages
The io/ioutil package has been deprecated as of Go 1.16, see
https://golang.org/doc/go1.16#ioutil. This commit replaces the existing
io/ioutil functions with their new definitions in io and os packages.
Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
* build: update snapcraft `go-channel` to 1.17
Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
* chore: script to build the deb sources
now it includes the man files. This script makes only sense executing
on the machine having the gpg key needed to sign and push to ppa
* fix: dput dependency and proper configuration
This put everything concerning golangci following [this](https://golangci-lint.run/usage/configuration/).
This way, anyone running golangci with a command line or with it's favorite Ide will use the same configuration for the current project.
The current implementation of the deepMatch() has the exponential runtime.
Given the long enough input and the pattern with multiple wildcards
it takes a while if ever to complete which can potentially be used
maliciously to cause a denial of service (cpu and memory consumption).
E.g. running this in the root of this repository
time yq eval '.jobs.publishDocker.steps.[] | select (.run == "****outputs")' .github/workflows/release.yml
gives on my laptop
25.11s user 0.06s system 99% cpu 25.182 total
Whereas the updated implementation gives
0.01s user 0.01s system 36% cpu 0.049 total
There are numerous similar CVEs reported for glob evaluation in
different shells/ftp-servers/libraries.
The replacement implementation with the linear runtime is shamelessly taken
verbatim from the briliant article by Russ Cox https://research.swtch.com/glob
Installation by go will result in an error:
module declares its path as: xxx,
but was required as: xxx.
Go install with master branch will fix it.
fix: #676
json.Encoder and json.Marshal implicitly use HTMLEscape to convert
>, <, &, with \u003c, \u003e, \u0026. This behavior carries over
to yq, where chars will be escaped when outputting json but not when
outputting yaml.
This changeset disables this behavior via encoder.SetEscapeHTML(false).
Unfortunately there is no equivalent option for json.Marshal, so its
single usage has been replaced with an encoder (with escaping disabled).
The program generates a path for every leaf node in the
file-to-be-merged. It does not escape them if they contain a dot, as
the path-expressions document mentions is necessary.
Add in a test for this condition. Verified it fails without the fix.
- Move data_navigator, json_converter, merge, and path_parser to pkg/yqlib
- Extract yamlToString from yq to pkg/yqlib/yaml_converter
- Move utils_test to test/utils
When there is no match at a given path, numeric keys are assumed to be strings.
To create an array '+' must be used.
e.g: yq n thing[+].cat fred
will create an array under thing, whereas
yq n thing[0].cat fred
will create a map under thing, with a key '0'
The delete (short option "d") will delete the YAML subtree at the
provided path in the specified file (or STDIN), if it the node exists.
More complex support is currently omitted, for example:
- specify nodes to delete using an external script
- deleting common elements from all elements of an array
Although printing the string as a yaml block can be argued to be technically correct, in practical terms it's more useful to just print out the multiline string as is.
1. Run `scripts/devtools.sh` to install the required devtools
2. Run `make [local] vendor` to install the vendor dependencies
2. Run `make [local] test` to ensure you can run the existing tests
3. Write unit tests - (see existing examples). Changes will not be accepted without corresponding unit tests.
4. Make the code changes.
5.`make [local] test` to lint code and run tests
6. Profit! ok no profit, but raise a PR and get kudos :)
# Documentation
The documentation is a bit of a mixed bag (sorry in advance, I do plan on simplifying it...) - with some parts automatically generated and stiched together and some statically defined.
Documentation is written in markdown, and is published in the 'gitbook' branch.
The various operator documentation (e.g. 'strings') are generated from the 'master' branch, and have a statically defined header (e.g. `pkg/yqlib/doc/operators/headers/add.md`) and the bulk of the docs are generated from the unit tests e.g. `pkg/yqlib/operator_add_test.go`.
The pipeline will run the tests and automatically concatenate the files together, and put them under
`pkg/qylib/doc/add.md`. These files are checked in the master branch (and are copied to the gitbook branch as part of the release process).
## How to contribute
The first step is to find if what you want is automatically generated or not - start by looking in the master branch.
Note that PRs with small changes (e.g. minor typos) may not be merged (see https://joel.net/how-one-guy-ruined-hacktoberfest2020-drama).
### Updating dynamic documentation from master
- Search for the documentation you want to update. If you find matches in a `*_test.go` file - update that, as that will automatically update the matching `*.md` file
- Assuming you are updating a `*_test.go` file, once updated, run the test to regenerated the docs. E.g. for the 'Add' test generated docs, from the pkg/yqlib folder run:
`go test -run TestAddOperatorScenarios` which will run that test defined in the `operator_add_test.go` file.
- Ensure the tests still pass, and check the generated documentation have your update.
- Note: If the documentation is only in a `headers/*.md` file, then just update that directly
- Raise a PR to merge the changes into master!
### Updating static documentation from the gitbook branch
If you haven't found what you want to update in the master branch, then check the gitbook branch directly as there are a few pages in there that are not in master.
a lightweight and portable command-line YAML, JSON, INI and XML processor. `yq` uses [jq](https://github.com/stedolan/jq) like syntax but works with yaml files as well as json, xml, ini, properties, csv and tsv. It doesn't yet support everything `jq` does - but it does support the most common operations and functions, and more is being added continuously.
yq is written in go - so you can download a dependency free binary for your platform and you are good to go! If you prefer there are a variety of package managers that can be used as well as Docker and Podman, all listed below.
See [recipes](https://mikefarah.gitbook.io/yq/recipes) for more examples and the [documentation](https://mikefarah.gitbook.io/yq/) for more information.
Take a look at the discussions for [common questions](https://github.com/mikefarah/yq/discussions/categories/q-a), and [cool ideas](https://github.com/mikefarah/yq/discussions/categories/show-and-tell)
## Install
[Download latest binary](https://github.com/mikefarah/yq/releases/latest) or alternatively:
### [Download the latest binary](https://github.com/mikefarah/yq/releases/latest)
### wget
Use wget to download, gzipped pre-compiled binaries:
For instance, VERSION=v4.2.0 and BINARY=yq_linux_amd64
`yq` installs with [_strict confinement_](https://docs.snapcraft.io/snap-confinement/6233) in snap, this means it doesn't have direct access to root files. To read root files you can:
```
sudo cat /etc/myfile | yq '.a.path'
```
And to write to a root file you can either use [sponge](https://linux.die.net/man/1/sponge):
docker run --rm -v "${PWD}":/workdir mikefarah/yq [command][flags][expression ]FILE...
```
Note that you can run `yq` in docker without network access and other privileges if you desire,
namely `--security-opt=no-new-privileges --cap-drop all --network none`.
```bash
podman run --rm -v "${PWD}":/workdir mikefarah/yq [command][flags][expression ]FILE...
```
#### Pipe in via STDIN:
You'll need to pass the `-i\--interactive` flag to docker:
```bash
docker run -i --rm mikefarah/yq '.this.thing' < myfile.yml
```
```bash
podman run -i --rm mikefarah/yq '.this.thing' < myfile.yml
```
#### Run commands interactively:
```bash
docker run --rm -it -v "${PWD}":/workdir --entrypoint sh mikefarah/yq
```
```bash
podman run --rm -it -v "${PWD}":/workdir --entrypoint sh mikefarah/yq
```
It can be useful to have a bash function to avoid typing the whole docker command:
```bash
yq(){
docker run --rm -i -v "${PWD}":/workdir mikefarah/yq "$@"
}
```
```bash
yq(){
podman run --rm -i -v "${PWD}":/workdir mikefarah/yq "$@"
}
```
#### Running as root:
`yq`'s container image no longer runs under root (https://github.com/mikefarah/yq/pull/860). If you'd like to install more things in the container image, or you're having permissions issues when attempting to read/write files you'll need to either:
```
docker run --user="root" -it --entrypoint sh mikefarah/yq
```
```
podman run --user="root" -it --entrypoint sh mikefarah/yq
```
Or, in your Dockerfile:
```
FROM mikefarah/yq
USER root
RUN apk add --no-cache bash
USER yq
```
#### Missing timezone data
By default, the alpine image yq uses does not include timezone data. If you'd like to use the `tz` operator, you'll need to include this data:
```
FROM mikefarah/yq
USER root
RUN apk add --no-cache tzdata
USER yq
```
#### Podman with SELinux
If you are using podman with SELinux, you will need to set the shared volume flag `:z` on the volume mount:
```
-v "${PWD}":/workdir:z
```
### GitHub Action
```
- name: Set foobar to cool
uses: mikefarah/yq@master
with:
cmd: yq -i '.foo.bar = "cool"' 'config.yml'
- name: Get an entry with a variable that might contain dots or spaces
Supported by @chillum (https://chocolatey.org/packages/yq)
Using [scoop](https://scoop.sh/)
```
scoop install main/yq
```
Using [winget](https://learn.microsoft.com/en-us/windows/package-manager/)
```
winget install --id MikeFarah.yq
```
### Mac:
Using [MacPorts](https://www.macports.org/)
```
sudo port selfupdate
sudo port install yq
```
Supported by @herbygillot (https://ports.macports.org/maintainer/github/herbygillot)
### Alpine Linux
Alpine Linux v3.20+ (and Edge):
```
apk add yq-go
```
Alpine Linux up to v3.19:
```
apk add yq
```
Supported by Tuan Hoang (https://pkgs.alpinelinux.org/packages?name=yq-go)
### Flox:
Flox can be used to install yq on Linux, MacOS, and Windows through WSL.
```
flox install yq
```
## Features
- [Detailed documentation with many examples](https://mikefarah.gitbook.io/yq/)
- Written in portable go, so you can download a lovely dependency free binary
-Deep read a yaml file with a given path
-Update a yaml file given a path
-Update a yaml file given a script file
-Update creates any missing entries in the path on the fly
-Create a yaml file given a deep path and value
-Create a yaml file given a script file
-Convert from json to yaml
-Convert from yaml to json
-Pipe data in by using '-'
-Merge multiple yaml files where each additional file sets values for missing or null value keys.
-Merge multiple yaml files with overwrite to support overriding previous values.
-Uses similar syntax as `jq` but works with YAML, INI, [JSON](https://mikefarah.gitbook.io/yq/usage/convert) and [XML](https://mikefarah.gitbook.io/yq/usage/xml) files
-Manipulate yaml [comments](https://mikefarah.gitbook.io/yq/operators/comment-operators), [styling](https://mikefarah.gitbook.io/yq/operators/style), [tags](https://mikefarah.gitbook.io/yq/operators/tag) and [anchors and aliases](https://mikefarah.gitbook.io/yq/operators/anchor-and-alias-operators).
-[Update in place](https://mikefarah.gitbook.io/yq/v/v4.x/commands/evaluate#flags)
-[Complex expressions to select and update](https://mikefarah.gitbook.io/yq/operators/select#select-and-update-matching-values-in-map)
-Keeps yaml formatting and comments when updating (though there are issues with whitespace)
--csv-separator char CSV Separator character (default ,)
-e, --exit-status set exit status if there are no matches or null or false is returned
--expression string forcibly set the expression argument. Useful when yq argument detection thinks your expression is a file.
--from-file string Load expression from specified file.
-f, --front-matter string (extract|process) first input as yaml front-matter. Extract will pull out the yaml content, process will run the expression against the yaml content, leaving the remaining data intact
--header-preprocess Slurp any header comments and separators before processing expression. (default true)
-h, --help help for yq
-I, --indent int sets indent level for output (default 2)
-i, --inplace update the file in place of first file given.
-p, --input-format string [auto|a|yaml|y|json|j|props|p|csv|c|tsv|t|xml|x|base64|uri|toml|lua|l|ini|i] parse format for input. (default "auto")
--lua-globals output keys as top-level global variables
-0, --nul-output Use NUL char to separate values. If unwrap scalar is also set, fail if unwrapped scalar contains NUL char.
-n, --null-input Don't read input, simply evaluate the expression given. Useful for creating docs from scratch.
-o, --output-format string [auto|a|yaml|y|json|j|props|p|csv|c|tsv|t|xml|x|base64|uri|toml|shell|s|lua|l|ini|i] output format type. (default "auto")
-P, --prettyPrint pretty print, shorthand for '... style = ""'
--properties-array-brackets use [x] in array paths (e.g. for SpringBoot)
--properties-separator string separator to use between keys and values (default " = ")
-s, --split-exp string print each result (or doc) into a file named (exp). [exp] argument must return a string. You can use $index in the expression as the result counter. The necessary directories will be created.
--split-exp-file string Use a file to specify the split-exp expression.
--string-interpolation Toggles strings interpolation of \(exp) (default true)
-r, --unwrapScalar unwrap scalar, print the value with no quotes, colors or comments. Defaults to true for yaml (default true)
-v, --verbose verbose mode
-V, --version Print version information and quit
--xml-attribute-prefix string prefix for xml attributes (default "+@")
--xml-content-name string name for xml content (if no attribute name is present). (default "+content")
--xml-directive-name string name for xml directives (e.g. <!DOCTYPE thing cat>) (default "+directive")
--xml-keep-namespace enables keeping namespace after parsing attributes (default true)
--xml-proc-inst-prefix string prefix for xml processing instructions (e.g. <?xml version="1"?>) (default "+p_")
--xml-raw-token enables using RawToken method instead Token. Commonly disables namespace translations. See https://pkg.go.dev/encoding/xml#Decoder.RawToken for details. (default true)
--xml-skip-directives skip over directives (e.g. <!DOCTYPE thing cat>)
--xml-skip-proc-inst skip over process instructions (e.g. <?xml version="1"?>)
--xml-strict-mode enables strict parsing of XML. See https://pkg.go.dev/encoding/xml for more details.
Use "yq [command] --help" for more information about a command.
```
## Known Issues / Missing Features
-`yq` attempts to preserve comment positions and whitespace as much as possible, but it does not handle all scenarios (see https://github.com/go-yaml/yaml/tree/v3 for details)
- Powershell has its own...[opinions on quoting yq](https://mikefarah.gitbook.io/yq/usage/tips-and-tricks#quotes-in-windows-powershell)
- "yes", "no" were dropped as boolean values in the yaml 1.2 standard - which is the standard yq assumes.
## Contribute
1.`make [local] vendor`
2. add unit tests
3. apply changes
4.`make [local] build`
5. profit
See [tips and tricks](https://mikefarah.gitbook.io/yq/usage/tips-and-tricks) for more common problems and solutions.
rootCmd.PersistentFlags().BoolVarP(&outputToJSON,"tojson","j",false,"(deprecated) output as json. Set indent to 0 to print json in one line.")
err:=rootCmd.PersistentFlags().MarkDeprecated("tojson","please use -o=json instead")
iferr!=nil{
panic(err)
}
rootCmd.PersistentFlags().StringVarP(&outputFormat,"output-format","o","auto",fmt.Sprintf("[auto|a|%v] output format type.",yqlib.GetAvailableOutputFormatString()))
rootCmd.PersistentFlags().StringVarP(&inputFormat,"input-format","p","auto",fmt.Sprintf("[auto|a|%v] parse format for input.",yqlib.GetAvailableInputFormatString()))
rootCmd.PersistentFlags().StringVar(&yqlib.ConfiguredXMLPreferences.AttributePrefix,"xml-attribute-prefix",yqlib.ConfiguredXMLPreferences.AttributePrefix,"prefix for xml attributes")
rootCmd.PersistentFlags().StringVar(&yqlib.ConfiguredXMLPreferences.ContentName,"xml-content-name",yqlib.ConfiguredXMLPreferences.ContentName,"name for xml content (if no attribute name is present).")
rootCmd.PersistentFlags().BoolVar(&yqlib.ConfiguredXMLPreferences.StrictMode,"xml-strict-mode",yqlib.ConfiguredXMLPreferences.StrictMode,"enables strict parsing of XML. See https://pkg.go.dev/encoding/xml for more details.")
rootCmd.PersistentFlags().BoolVar(&yqlib.ConfiguredXMLPreferences.KeepNamespace,"xml-keep-namespace",yqlib.ConfiguredXMLPreferences.KeepNamespace,"enables keeping namespace after parsing attributes")
rootCmd.PersistentFlags().BoolVar(&yqlib.ConfiguredXMLPreferences.UseRawToken,"xml-raw-token",yqlib.ConfiguredXMLPreferences.UseRawToken,"enables using RawToken method instead Token. Commonly disables namespace translations. See https://pkg.go.dev/encoding/xml#Decoder.RawToken for details.")
rootCmd.PersistentFlags().StringVar(&yqlib.ConfiguredXMLPreferences.ProcInstPrefix,"xml-proc-inst-prefix",yqlib.ConfiguredXMLPreferences.ProcInstPrefix,"prefix for xml processing instructions (e.g. <?xml version=\"1\"?>)")
rootCmd.PersistentFlags().StringVar(&yqlib.ConfiguredXMLPreferences.DirectiveName,"xml-directive-name",yqlib.ConfiguredXMLPreferences.DirectiveName,"name for xml directives (e.g. <!DOCTYPE thing cat>)")
rootCmd.PersistentFlags().BoolVar(&yqlib.ConfiguredXMLPreferences.SkipProcInst,"xml-skip-proc-inst",yqlib.ConfiguredXMLPreferences.SkipProcInst,"skip over process instructions (e.g. <?xml version=\"1\"?>)")
rootCmd.PersistentFlags().BoolVar(&yqlib.ConfiguredXMLPreferences.SkipDirectives,"xml-skip-directives",yqlib.ConfiguredXMLPreferences.SkipDirectives,"skip over directives (e.g. <!DOCTYPE thing cat>)")
rootCmd.PersistentFlags().BoolVar(&yqlib.ConfiguredLuaPreferences.Globals,"lua-globals",yqlib.ConfiguredLuaPreferences.Globals,"output keys as top-level global variables")
rootCmd.PersistentFlags().StringVar(&yqlib.ConfiguredPropertiesPreferences.KeyValueSeparator,"properties-separator",yqlib.ConfiguredPropertiesPreferences.KeyValueSeparator,"separator to use between keys and values")
rootCmd.PersistentFlags().BoolVar(&yqlib.ConfiguredPropertiesPreferences.UseArrayBrackets,"properties-array-brackets",yqlib.ConfiguredPropertiesPreferences.UseArrayBrackets,"use [x] in array paths (e.g. for SpringBoot)")
rootCmd.PersistentFlags().BoolVar(&yqlib.StringInterpolationEnabled,"string-interpolation",yqlib.StringInterpolationEnabled,"Toggles strings interpolation of \\(exp)")
rootCmd.PersistentFlags().BoolVarP(&nullInput,"null-input","n",false,"Don't read input, simply evaluate the expression given. Useful for creating docs from scratch.")
rootCmd.Flags().BoolVarP(&version,"version","V",false,"Print version information and quit")
rootCmd.PersistentFlags().BoolVarP(&writeInplace,"inplace","i",false,"update the file in place of first file given.")
rootCmd.PersistentFlags().VarP(unwrapScalarFlag,"unwrapScalar","r","unwrap scalar, print the value with no quotes, colors or comments. Defaults to true for yaml")
rootCmd.PersistentFlags().BoolVarP(&nulSepOutput,"nul-output","0",false,"Use NUL char to separate values. If unwrap scalar is also set, fail if unwrapped scalar contains NUL char.")
rootCmd.PersistentFlags().BoolVarP(&prettyPrint,"prettyPrint","P",false,"pretty print, shorthand for '... style = \"\"'")
rootCmd.PersistentFlags().BoolVarP(&exitStatus,"exit-status","e",false,"set exit status if there are no matches or null or false is returned")
rootCmd.PersistentFlags().BoolVarP(&forceColor,"colors","C",false,"force print with colors")
rootCmd.PersistentFlags().BoolVarP(&forceNoColor,"no-colors","M",forceNoColor,"force print with no colors")
rootCmd.PersistentFlags().StringVarP(&frontMatter,"front-matter","f","","(extract|process) first input as yaml front-matter. Extract will pull out the yaml content, process will run the expression against the yaml content, leaving the remaining data intact")
rootCmd.PersistentFlags().StringVarP(&forceExpression,"expression","","","forcibly set the expression argument. Useful when yq argument detection thinks your expression is a file.")
rootCmd.PersistentFlags().BoolVarP(&yqlib.ConfiguredYamlPreferences.LeadingContentPreProcessing,"header-preprocess","",true,"Slurp any header comments and separators before processing expression.")
rootCmd.PersistentFlags().BoolVarP(&yqlib.ConfiguredYamlPreferences.FixMergeAnchorToSpec,"yaml-fix-merge-anchor-to-spec","",false,"Fix merge anchor to match YAML spec. Will default to true in late 2025")
rootCmd.PersistentFlags().StringVarP(&splitFileExp,"split-exp","s","","print each result (or doc) into a file named (exp). [exp] argument must return a string. You can use $index in the expression as the result counter. The necessary directories will be created.")
yqlib.GetLogger().Warning("yq default output is now 'auto' (based on the filename extension). Normally yq would output '%v', but for backwards compatibility 'yaml' has been set. Please use -oy to specify yaml, or drop the -p flag.",outputFormat)
!function(e,r){"function"==typeofdefine&&define.amd?define(r):"object"==typeofexports?module.exports=r():r()(e.lunr)}(this,function(){returnfunction(e){if(void0===e)thrownewError("Lunr is not present. Please include / require Lunr before this script.");if(void0===e.stemmerSupport)thrownewError("Lunr stemmer support is not present. Please include / require Lunr stemmer support before this script.");e.da=function(){this.pipeline.reset(),this.pipeline.add(e.da.trimmer,e.da.stopWordFilter,e.da.stemmer),this.searchPipeline&&(this.searchPipeline.reset(),this.searchPipeline.add(e.da.stemmer))},e.da.wordCharacters="A-Za-zªºÀ-ÖØ-öø-ʸˠ-ˤᴀ-ᴥᴬ-ᵜᵢ-ᵥᵫ-ᵷᵹ-ᶾḀ-ỿⁱⁿₐ-ₜKÅℲⅎⅠ-ↈⱠ-ⱿꜢ-ꞇꞋ-ꞭꞰ-ꞷꟷ-ꟿꬰ-ꭚꭜ-ꭤff-stA-Za-z",e.da.trimmer=e.trimmerSupport.generateTrimmer(e.da.wordCharacters),e.Pipeline.registerFunction(e.da.trimmer,"trimmer-da"),e.da.stemmer=function(){varr=e.stemmerSupport.Among,i=e.stemmerSupport.SnowballProgram,n=newfunction(){functione(){vare,r=f.cursor+3;if(d=f.limit,0<=r&&r<=f.limit){for(a=r;;){if(e=f.cursor,f.in_grouping(w,97,248)){f.cursor=e;break}if(f.cursor=e,e>=f.limit)return;f.cursor++}for(;!f.out_grouping(w,97,248);){if(f.cursor>=f.limit)return;f.cursor++}(d=f.cursor)<a&&(d=a)}}functionn(){vare,r;if(f.cursor>=d&&(r=f.limit_backward,f.limit_backward=d,f.ket=f.cursor,e=f.find_among_b(c,32),f.limit_backward=r,e))switch(f.bra=f.cursor,e){case1:f.slice_del();break;case2:f.in_grouping_b(p,97,229)&&f.slice_del()}}functiont(){vare,r=f.limit-f.cursor;f.cursor>=d&&(e=f.limit_backward,f.limit_backward=d,f.ket=f.cursor,f.find_among_b(l,4)?(f.bra=f.cursor,f.limit_backward=e,f.cursor=f.limit-r,f.cursor>f.limit_backward&&(f.cursor--,f.bra=f.cursor,f.slice_del())):f.limit_backward=e)}functions(){vare,r,i,n=f.limit-f.cursor;if(f.ket=f.cursor,f.eq_s_b(2,"st")&&(f.bra=f.cursor,f.eq_s_b(2,"ig")&&f.slice_del()),f.cursor=f.limit-n,f.cursor>=d&&(r=f.limit_backward,f.limit_backward=d,f.ket=f.cursor,e=f.find_among_b(m,5),f.limit_backward=r,e))switch(f.bra=f.cursor,e){case1:f.slice_del(),i=f.limit-f.cursor,t(),f.cursor=f.limit-i;break;case2:f.slice_from("løs")}}functiono(){vare;f.cursor>=d&&(e=f.limit_backward,f.limit_backward=d,f.ket=f.cursor,f.out_grouping_b(w,97,248)?(f.bra=f.cursor,u=f.slice_to(u),f.limit_backward=e,f.eq_v_b(u)&&f.slice_del()):f.limit_backward=e)}vara,d,u,c=[newr("hed",-1,1),newr("ethed",0,1),newr("ered",-1,1),newr("e",-1,1),newr("erede",3,1),newr("ende",3,1),newr("erende",5,1),newr("ene",3,1),newr("erne",3,1),newr("ere",3,1),newr("en",-1,1),newr("heden",10,1),newr("eren",10,1),newr("er",-1,1),newr("heder",13,1),newr("erer",13,1),newr("s",-1,2),newr("heds",16,1),newr("es",16,1),newr("endes",18,1),newr("erendes",19,1),newr("enes",18,1),newr("ernes",18,1),newr("eres",18,1),newr("ens",16,1),newr("hedens",24,1),newr("erens",24,1),newr("ers",16,1),newr("ets",16,1),newr("erets",28,1),newr("et",-1,1),newr("eret",30,1)],l=[newr("gd",-1,-1),newr("dt",-1,-1),newr("gt",-1,-1),newr("kt",-1,-1)],m=[newr("ig",-1,1),newr("lig",0,1),newr("elig",1,1),newr("els",-1,1),newr("løst",-1,2)],w=[17,65,16,1,0,0,0,0,0,0,0,0,0,0,0,0,48,0,128],p=[239,254,42,3,0,0,0,0,0,0,0,0,0,0,0,0,16],f=newi;this.setCurrent=function(e){f.setCurrent(e)},this.getCurrent=function(){returnf.getCurrent()},this.stem=function(){varr=f.cursor;returne(),f.limit_backward=r,f.cursor=f.limit,n(),f.cursor=f.limit,t(),f.cursor=f.limit,s(),f.cursor=f.limit,o(),!0}};returnfunction(e){return"function"==typeofe.update?e.update(function(e){returnn.setCurrent(e),n.stem(),n.getCurrent()}):(n.setCurrent(e),n.stem(),n.getCurrent())}}(),e.Pipeline.registerFunction(e.da.stemmer,"stemmer-da"),e.da.stopWordFilter=e.generateStopWordFilter("ad af alle alt anden at blev blive bliver da de dem den denne der deres det dette dig din disse dog du efter eller en end er et for fra ham han hans har havde have hende hendes her hos hun hvad hvis hvor i ikke ind jeg jer jo kunne man mange med meget men mig min mine mit mod ned noget nogle nu når og også om op os over på selv sig sin sine sit skal skulle som sådan thi til ud under var vi vil ville vor være været".split(" ")),e.Pipeline.registerFunction(e.da.stopWordFilter,"stopWordFilter-da")}});
!function(e,r){"function"==typeofdefine&&define.amd?define(r):"object"==typeofexports?module.exports=r():r()(e.lunr)}(this,function(){returnfunction(e){if(void0===e)thrownewError("Lunr is not present. Please include / require Lunr before this script.");if(void0===e.stemmerSupport)thrownewError("Lunr stemmer support is not present. Please include / require Lunr stemmer support before this script.");e.no=function(){this.pipeline.reset(),this.pipeline.add(e.no.trimmer,e.no.stopWordFilter,e.no.stemmer),this.searchPipeline&&(this.searchPipeline.reset(),this.searchPipeline.add(e.no.stemmer))},e.no.wordCharacters="A-Za-zªºÀ-ÖØ-öø-ʸˠ-ˤᴀ-ᴥᴬ-ᵜᵢ-ᵥᵫ-ᵷᵹ-ᶾḀ-ỿⁱⁿₐ-ₜKÅℲⅎⅠ-ↈⱠ-ⱿꜢ-ꞇꞋ-ꞭꞰ-ꞷꟷ-ꟿꬰ-ꭚꭜ-ꭤff-stA-Za-z",e.no.trimmer=e.trimmerSupport.generateTrimmer(e.no.wordCharacters),e.Pipeline.registerFunction(e.no.trimmer,"trimmer-no"),e.no.stemmer=function(){varr=e.stemmerSupport.Among,n=e.stemmerSupport.SnowballProgram,i=newfunction(){functione(){vare,r=w.cursor+3;if(a=w.limit,0<=r||r<=w.limit){for(s=r;;){if(e=w.cursor,w.in_grouping(d,97,248)){w.cursor=e;break}if(e>=w.limit)return;w.cursor=e+1}for(;!w.out_grouping(d,97,248);){if(w.cursor>=w.limit)return;w.cursor++}(a=w.cursor)<s&&(a=s)}}functioni(){vare,r,n;if(w.cursor>=a&&(r=w.limit_backward,w.limit_backward=a,w.ket=w.cursor,e=w.find_among_b(m,29),w.limit_backward=r,e))switch(w.bra=w.cursor,e){case1:w.slice_del();break;case2:n=w.limit-w.cursor,w.in_grouping_b(c,98,122)?w.slice_del():(w.cursor=w.limit-n,w.eq_s_b(1,"k")&&w.out_grouping_b(d,97,248)&&w.slice_del());break;case3:w.slice_from("er")}}functiont(){vare,r=w.limit-w.cursor;w.cursor>=a&&(e=w.limit_backward,w.limit_backward=a,w.ket=w.cursor,w.find_among_b(u,2)?(w.bra=w.cursor,w.limit_backward=e,w.cursor=w.limit-r,w.cursor>w.limit_backward&&(w.cursor--,w.bra=w.cursor,w.slice_del())):w.limit_backward=e)}functiono(){vare,r;w.cursor>=a&&(r=w.limit_backward,w.limit_backward=a,w.ket=w.cursor,(e=w.find_among_b(l,11))?(w.bra=w.cursor,w.limit_backward=r,1==e&&w.slice_del()):w.limit_backward=r)}vars,a,m=[newr("a",-1,1),newr("e",-1,1),newr("ede",1,1),newr("ande",1,1),newr("ende",1,1),newr("ane",1,1),newr("ene",1,1),newr("hetene",6,1),newr("erte",1,3),newr("en",-1,1),newr("heten",9,1),newr("ar",-1,1),newr("er",-1,1),newr("heter",12,1),newr("s",-1,2),newr("as",14,1),newr("es",14,1),newr("edes",16,1),newr("endes",16,1),newr("enes",16,1),newr("hetenes",19,1),newr("ens",14,1),newr("hetens",21,1),newr("ers",14,1),newr("ets",14,1),newr("et",-1,1),newr("het",25,1),newr("ert",-1,3),newr("ast",-1,1)],u=[newr("dt",-1,-1),newr("vt",-1,-1)],l=[newr("leg",-1,1),newr("eleg",0,1),newr("ig",-1,1),newr("eig",2,1),newr("lig",2,1),newr("elig",4,1),newr("els",-1,1),newr("lov",-1,1),newr("elov",7,1),newr("slov",7,1),newr("hetslov",9,1)],d=[17,65,16,1,0,0,0,0,0,0,0,0,0,0,0,0,48,0,128],c=[119,125,149,1],w=newn;this.setCurrent=function(e){w.setCurrent(e)},this.getCurrent=function(){returnw.getCurrent()},this.stem=function(){varr=w.cursor;returne(),w.limit_backward=r,w.cursor=w.limit,i(),w.cursor=w.limit,t(),w.cursor=w.limit,o(),!0}};returnfunction(e){return"function"==typeofe.update?e.update(function(e){returni.setCurrent(e),i.stem(),i.getCurrent()}):(i.setCurrent(e),i.stem(),i.getCurrent())}}(),e.Pipeline.registerFunction(e.no.stemmer,"stemmer-no"),e.no.stopWordFilter=e.generateStopWordFilter("alle at av bare begge ble blei bli blir blitt både båe da de deg dei deim deira deires dem den denne der dere deres det dette di din disse ditt du dykk dykkar då eg ein eit eitt eller elles en enn er et ett etter for fordi fra før ha hadde han hans har hennar henne hennes her hjå ho hoe honom hoss hossen hun hva hvem hver hvilke hvilken hvis hvor hvordan hvorfor i ikke ikkje ikkje ingen ingi inkje inn inni ja jeg kan kom korleis korso kun kunne kva kvar kvarhelst kven kvi kvifor man mange me med medan meg meget mellom men mi min mine mitt mot mykje ned no noe noen noka noko nokon nokor nokre nå når og også om opp oss over på samme seg selv si si sia sidan siden sin sine sitt sjøl skal skulle slik so som som somme somt så sånn til um upp ut uten var vart varte ved vere verte vi vil ville vore vors vort vår være være vært å".split(" ")),e.Pipeline.registerFunction(e.no.stopWordFilter,"stopWordFilter-no")}});
!function(e,r){"function"==typeofdefine&&define.amd?define(r):"object"==typeofexports?module.exports=r():r()(e.lunr)}(this,function(){returnfunction(e){if(void0===e)thrownewError("Lunr is not present. Please include / require Lunr before this script.");if(void0===e.stemmerSupport)thrownewError("Lunr stemmer support is not present. Please include / require Lunr stemmer support before this script.");e.sv=function(){this.pipeline.reset(),this.pipeline.add(e.sv.trimmer,e.sv.stopWordFilter,e.sv.stemmer),this.searchPipeline&&(this.searchPipeline.reset(),this.searchPipeline.add(e.sv.stemmer))},e.sv.wordCharacters="A-Za-zªºÀ-ÖØ-öø-ʸˠ-ˤᴀ-ᴥᴬ-ᵜᵢ-ᵥᵫ-ᵷᵹ-ᶾḀ-ỿⁱⁿₐ-ₜKÅℲⅎⅠ-ↈⱠ-ⱿꜢ-ꞇꞋ-ꞭꞰ-ꞷꟷ-ꟿꬰ-ꭚꭜ-ꭤff-stA-Za-z",e.sv.trimmer=e.trimmerSupport.generateTrimmer(e.sv.wordCharacters),e.Pipeline.registerFunction(e.sv.trimmer,"trimmer-sv"),e.sv.stemmer=function(){varr=e.stemmerSupport.Among,n=e.stemmerSupport.SnowballProgram,t=newfunction(){functione(){vare,r=w.cursor+3;if(o=w.limit,0<=r||r<=w.limit){for(a=r;;){if(e=w.cursor,w.in_grouping(l,97,246)){w.cursor=e;break}if(w.cursor=e,w.cursor>=w.limit)return;w.cursor++}for(;!w.out_grouping(l,97,246);){if(w.cursor>=w.limit)return;w.cursor++}(o=w.cursor)<a&&(o=a)}}functiont(){vare,r=w.limit_backward;if(w.cursor>=o&&(w.limit_backward=o,w.cursor=w.limit,w.ket=w.cursor,e=w.find_among_b(u,37),w.limit_backward=r,e))switch(w.bra=w.cursor,e){case1:w.slice_del();break;case2:w.in_grouping_b(d,98,121)&&w.slice_del()}}functioni(){vare=w.limit_backward;w.cursor>=o&&(w.limit_backward=o,w.cursor=w.limit,w.find_among_b(c,7)&&(w.cursor=w.limit,w.ket=w.cursor,w.cursor>w.limit_backward&&(w.bra=--w.cursor,w.slice_del())),w.limit_backward=e)}functions(){vare,r;if(w.cursor>=o){if(r=w.limit_backward,w.limit_backward=o,w.cursor=w.limit,w.ket=w.cursor,e=w.find_among_b(m,5))switch(w.bra=w.cursor,e){case1:w.slice_del();break;case2:w.slice_from("lös");break;case3:w.slice_from("full")}w.limit_backward=r}}vara,o,u=[newr("a",-1,1),newr("arna",0,1),newr("erna",0,1),newr("heterna",2,1),newr("orna",0,1),newr("ad",-1,1),newr("e",-1,1),newr("ade",6,1),newr("ande",6,1),newr("arne",6,1),newr("are",6,1),newr("aste",6,1),newr("en",-1,1),newr("anden",12,1),newr("aren",12,1),newr("heten",12,1),newr("ern",-1,1),newr("ar",-1,1),newr("er",-1,1),newr("heter",18,1),newr("or",-1,1),newr("s",-1,2),newr("as",21,1),newr("arnas",22,1),newr("ernas",22,1),newr("ornas",22,1),newr("es",21,1),newr("ades",26,1),newr("andes",26,1),newr("ens",21,1),newr("arens",29,1),newr("hetens",29,1),newr("erns",21,1),newr("at",-1,1),newr("andet",-1,1),newr("het",-1,1),newr("ast",-1,1)],c=[newr("dd",-1,-1),newr("gd",-1,-1),newr("nn",-1,-1),newr("dt",-1,-1),newr("gt",-1,-1),newr("kt",-1,-1),newr("tt",-1,-1)],m=[newr("ig",-1,1),newr("lig",0,1),newr("els",-1,1),newr("fullt",-1,3),newr("löst",-1,2)],l=[17,65,16,1,0,0,0,0,0,0,0,0,0,0,0,0,24,0,32],d=[119,127,149],w=newn;this.setCurrent=function(e){w.setCurrent(e)},this.getCurrent=function(){returnw.getCurrent()},this.stem=function(){varr=w.cursor;returne(),w.limit_backward=r,w.cursor=w.limit,t(),w.cursor=w.limit,i(),w.cursor=w.limit,s(),!0}};returnfunction(e){return"function"==typeofe.update?e.update(function(e){returnt.setCurrent(e),t.stem(),t.getCurrent()}):(t.setCurrent(e),t.stem(),t.getCurrent())}}(),e.Pipeline.registerFunction(e.sv.stemmer,"stemmer-sv"),e.sv.stopWordFilter=e.generateStopWordFilter("alla allt att av blev bli blir blivit de dem den denna deras dess dessa det detta dig din dina ditt du där då efter ej eller en er era ert ett från för ha hade han hans har henne hennes hon honom hur här i icke ingen inom inte jag ju kan kunde man med mellan men mig min mina mitt mot mycket ni nu när någon något några och om oss på samma sedan sig sin sina sitta själv skulle som så sådan sådana sådant till under upp ut utan vad var vara varför varit varje vars vart vem vi vid vilka vilkas vilken vilket vår våra vårt än är åt över".split(" ")),e.Pipeline.registerFunction(e.sv.stopWordFilter,"stopWordFilter-sv")}});
<labelclass="md-nav__title"for="toc">Table of contents</label>
<ulclass="md-nav__list"data-md-scrollfix>
<liclass="md-nav__item">
<ahref="#creating-a-simple-yaml-file"title="Creating a simple yaml file"class="md-nav__link">
Creating a simple yaml file
</a>
</li>
<liclass="md-nav__item">
<ahref="#creating-using-a-create-script"title="Creating using a create script"class="md-nav__link">
Creating using a create script
</a>
</li>
<liclass="md-nav__item">
<ahref="#keys-with-dots"title="Keys with dots"class="md-nav__link">
Keys with dots
</a>
</li>
</ul>
</nav>
</div>
</div>
</div>
<divclass="md-content">
<articleclass="md-content__inner md-typeset">
<h1>Create</h1>
<p>Yaml files can be created using the 'new' command. This works in the same way as the write command, but you don't pass in an existing Yaml file.</p>
<pre><code>yaml n <path><new value>
</code></pre>
<h3id="creating-a-simple-yaml-file">Creating a simple yaml file<aclass="headerlink"href="#creating-a-simple-yaml-file"title="Permanent link">¶</a></h3>
<pre><codeclass="bash">yaml n b.c cat
</code></pre>
<p>will output:</p>
<pre><codeclass="yaml">b:
c: cat
</code></pre>
<h3id="creating-using-a-create-script">Creating using a create script<aclass="headerlink"href="#creating-using-a-create-script"title="Permanent link">¶</a></h3>
<p>Create scripts follow the same format as the update scripts.</p>
<p>Given a script create_instructions.yaml of:</p>
<pre><codeclass="yaml">b.c: 3
b.e[0].name: Howdy Partner
</code></pre>
<p>then</p>
<pre><codeclass="bash">yaml n -s create_instructions.yaml
</code></pre>
<p>will output:</p>
<pre><codeclass="yaml">b:
c: 3
e:
- name: Howdy Partner
</code></pre>
<p>You can also pipe the instructions in:</p>
<pre><codeclass="bash">cat create_instructions.yaml | yaml n -s -
</code></pre>
<h3id="keys-with-dots">Keys with dots<aclass="headerlink"href="#keys-with-dots"title="Permanent link">¶</a></h3>
<p>When specifying a key that has a dot use key lookup indicator.</p>
<pre><codeclass="yaml">b:
foo.bar: 7
</code></pre>
<pre><codeclass="bash">yaml r sample.yaml b[foo.bar]
</code></pre>
<pre><codeclass="bash">yaml w sample.yaml b[foo.bar] 9
</code></pre>
<p>Any valid yaml key can be specified as part of a key lookup.</p>
<pre><codeclass="bash">yaml m -x data1.yaml data2.yaml
</code></pre>
<p>will output:</p>
<pre><codeclass="yaml">a: other
b: [1, 2]
c:
test: 1
</code></pre>
<h3id="overwrite-values-with-arrays">Overwrite values with arrays<aclass="headerlink"href="#overwrite-values-with-arrays"title="Permanent link">¶</a></h3>
<p>Given a data1.yaml file of:</p>
<pre><codeclass="yaml">a: simple
b: [1, 2]
</code></pre>
<p>and data3.yaml file of:</p>
<pre><codeclass="yaml">b: [2, 3, 4]
c:
test: 2
other: true
d: false
</code></pre>
<p>then</p>
<pre><codeclass="bash">yaml m -x data1.yaml data3.yaml
</code></pre>
<p>will output:</p>
<pre><codeclass="yaml">a: simple
b: [2, 3, 4]
c:
test: 2
other: true
d: false
</code></pre>
<p>Notice that 'b' does not result in the merging of the values within an array. The underlying library does not
currently handle merging values within an array.</p>
d){vare=f.id,g=m(h,e);g&&(!a.depMatched[d]&&!c[e])&&(m(b,e)?(a.defineDep(d,r[e]),a.check()):F(g,b,c))}),c[f]=!0)}functionD(){vara,b,c=(a=1E3*j.waitSeconds)&&i.startTime+a<(newDate).getTime(),f=[],l=[],g=!1,h=!0;if(!W){W=!0;B(V,function(a){vari=a.map,j=i.id;if(a.enabled&&(i.isDefine||l.push(a),!a.error))if(!a.inited&&c)e(j)?g=b=!0:(f.push(j),d(j));elseif(!a.inited&&(a.fetched&&i.isDefine)&&(g=!0,!i.prefix))returnh=!1});if(c&&f.length)returna=C("timeout","Load timeout for modules: "+f,null,
q;e.enableBuildCallback&&(d&&G(d))&&(d.__requireJsBuild=!0);if("string"===typeofc){if(G(d))returnw(C("requireargs","Invalid require call"),m);if(a&&t(L,c))returnL[c](h[a.id]);if(g.get)returng.get(i,c,a,j);n=p(c,a,!1,!0);n=n.id;return!t(r,n)?w(C("notloaded",'Module name "'+n+'" has not been loaded yet for context: '+b+(a?"":". Use require([])"))):r[n]}J();i.nextTick(function(){J();q=s(p(null,a));q.skipMap=e.skipMap;q.init(c,d,m,{enabled:!0});D()});returnj}e=e||{};U(j,{isBrowser:z,toUrl:function(b){vard,
s(a).enable()},completeLoad:function(a){varb,c,d=m(j.shim,a)||{},g=d.exports;for(x();A.length;){c=A.shift();if(null===c[0]){c[0]=a;if(b)break;b=!0}elsec[0]===a&&(b=!0);E(c)}c=m(h,a);if(!b&&!t(r,a)&&c&&!c.inited){if(j.enforceDefine&&(!g||!da(g)))returne(a)?void0:w(C("nodefine","No define call for "+a,null,[a]));E([a,d.deps||[],d.exportsFn])}D()},nameToUrl:function(a,b,c){vard,e,h;(d=m(j.pkgs,a))&&(a=d);if(d=m(aa,a))returni.nameToUrl(d,b,c);if(g.jsExtRegExp.test(a))d=a+(b||"");else{d=j.paths;
!Y?(M=!0,e.attachEvent("onreadystatechange",b.onScriptLoad)):(e.addEventListener("load",b.onScriptLoad,!1),e.addEventListener("error",b.onScriptError,!1)),e.src=d,J=e,D?y.insertBefore(e,D):y.appendChild(e),J=null,e;if(ea)try{importScripts(d),b.completeLoad(c)}catch(m){b.onError(C("importscripts","importScripts failed for "+c+" at "+d,m,[c]))}};z&&!q.skipDataMain&&T(document.getElementsByTagName("script"),function(b){y||(y=b.parentNode);if(I=b.getAttribute("data-main"))returns=I,q.baseUrl||(E=s.split("/"),
"text":"yaml\n\n\nyaml is a lightweight and portable command-line YAML processor\n\n\nThe aim of the project is to be the \njq\n or sed of yaml files.\n\n\ndownload latest binary\n\n\nget the source\n\n\ngo get github.com/mikefarah/yaml\n\n\n\n\n.zip\n or \ntar.gz\n\n\nView on GitHub",
"title":"Install"
},
{
"location":"/#yaml",
"text":"yaml is a lightweight and portable command-line YAML processor The aim of the project is to be the jq or sed of yaml files.",
"title":"yaml"
},
{
"location":"/#download-latest-binary",
"text":"",
"title":"download latest binary"
},
{
"location":"/#get-the-source",
"text":"go get github.com/mikefarah/yaml .zip or tar.gz View on GitHub",
"title":"get the source"
},
{
"location":"/read/",
"text":"yaml r \nyaml_file|json_file\n \npath\n\n\n\n\n\nThis command can take a json file as input too, and will output yaml unless specified to export as json (-j)\n\n\nBasic\n\n\nGiven a sample.yaml file of:\n\n\nb:\n c: 2\n\n\n\n\nthen\n\n\nyaml r sample.yaml b.c\n\n\n\n\nwill output the value of '2'.\n\n\nFrom Stdin\n\n\nGiven a sample.yaml file of:\n\n\ncat sample.yaml | yaml r - b.c\n\n\n\n\nwill output the value of '2'.\n\n\nSplat\n\n\nGiven a sample.yaml file of:\n\n\n---\nbob:\n item1:\n cats: bananas\n item2:\n cats: apples\n\n\n\n\nthen\n\n\nyaml r sample.yaml bob.*.cats\n\n\n\n\nwill output\n\n\n- bananas\n- apples\n\n\n\n\nHandling '.' in the yaml key\n\n\nGiven a sample.yaml file of:\n\n\nb.x:\n c: 2\n\n\n\n\nthen\n\n\nyaml r sample.yaml \\\nb.x\\\n.c\n\n\n\n\nwill output the value of '2'.\n\n\nArrays\n\n\nYou can give an index to access a specific element:\ne.g.: given a sample file of\n\n\nb:\n e:\n - name: fred\n value: 3\n - name: sam\n value: 4\n\n\n\n\nthen\n\n\nyaml r sample.yaml b.e[1].name\n\n\n\n\nwill output 'sam'\n\n\nArray Splat\n\n\ne.g.: given a sample file of\n\n\nb:\n e:\n - name: fred\n value: 3\n - name: sam\n value: 4\n\n\n\n\nthen\n\n\nyaml r sample.yaml b.e[*].name\n\n\n\n\nwill output:\n\n\n- fred\n- sam\n\n\n\n\nKeys with dots\n\n\nWhen specifying a key that has a dot use key lookup indicator.\n\n\nb:\n foo.bar: 7\n\n\n\n\nyaml r sample.yaml b[foo.bar]\n\n\n\n\nyaml w sample.yaml b[foo.bar] 9\n\n\n\n\nAny valid yaml key can be specified as part of a key lookup.",
"title":"Read"
},
{
"location":"/read/#basic",
"text":"Given a sample.yaml file of: b:\n c: 2 then yaml r sample.yaml b.c will output the value of '2'.",
"title":"Basic"
},
{
"location":"/read/#from-stdin",
"text":"Given a sample.yaml file of: cat sample.yaml | yaml r - b.c will output the value of '2'.",
"title":"From Stdin"
},
{
"location":"/read/#splat",
"text":"Given a sample.yaml file of: ---\nbob:\n item1:\n cats: bananas\n item2:\n cats: apples then yaml r sample.yaml bob.*.cats will output - bananas\n- apples",
"title":"Splat"
},
{
"location":"/read/#handling-in-the-yaml-key",
"text":"Given a sample.yaml file of: b.x:\n c: 2 then yaml r sample.yaml \\ b.x\\ .c will output the value of '2'.",
"title":"Handling '.' in the yaml key"
},
{
"location":"/read/#arrays",
"text":"You can give an index to access a specific element:\ne.g.: given a sample file of b:\n e:\n - name: fred\n value: 3\n - name: sam\n value: 4 then yaml r sample.yaml b.e[1].name will output 'sam'",
"title":"Arrays"
},
{
"location":"/read/#array-splat",
"text":"e.g.: given a sample file of b:\n e:\n - name: fred\n value: 3\n - name: sam\n value: 4 then yaml r sample.yaml b.e[*].name will output: - fred\n- sam",
"title":"Array Splat"
},
{
"location":"/read/#keys-with-dots",
"text":"When specifying a key that has a dot use key lookup indicator. b:\n foo.bar: 7 yaml r sample.yaml b[foo.bar] yaml w sample.yaml b[foo.bar] 9 Any valid yaml key can be specified as part of a key lookup.",
"title":"Keys with dots"
},
{
"location":"/write/",
"text":"yaml w \nyaml_file|json_file\n \npath\n \nnew value\n\n\n\n\n\nThis command can take a json file as input too, and will output yaml unless specified to export as json (-j)\n\n\nTo Stdout\n\n\nGiven a sample.yaml file of:\n\n\nb:\n c: 2\n\n\n\n\nthen\n\n\nyaml w sample.yaml b.c cat\n\n\n\n\nwill output:\n\n\nb:\n c: cat\n\n\n\n\nFrom STDIN\n\n\ncat sample.yaml | yaml w - b.c blah\n\n\n\n\nAdding new fields\n\n\nAny missing fields in the path will be created on the fly.\n\n\nGiven a sample.yaml file of:\n\n\nb:\n c: 2\n\n\n\n\nthen\n\n\nyaml w sample.yaml b.d[0] \nnew thing\n\n\n\n\n\nwill output:\n\n\nb:\n c: cat\n d:\n - new thing\n\n\n\n\nAppending value to an array field\n\n\nGiven a sample.yaml file of:\n\n\nb:\n c: 2\n d:\n - new thing\n - foo thing\n\n\n\n\nthen\n\n\nyaml w sample.yaml b.d[+] \nbar thing\n\n\n\n\n\nwill output:\n\n\nb:\n c: cat\n d:\n - new thing\n - foo thing\n - bar thing\n\n\n\n\nUpdating files in-place\n\n\nGiven a sample.yaml file of:\n\n\nb:\n c: 2\n\n\n\n\nthen\n\n\nyaml w -i sample.yaml b.c cat\n\n\n\n\nwill update the sample.yaml file so that the value of 'c' is cat.\n\n\nUpdating multiple values with a script\n\n\nGiven a sample.yaml file of:\n\n\nb:\n c: 2\n e:\n - name: Billy Bob\n\n\n\n\nand a script update_instructions.yaml of:\n\n\nb.c: 3\nb.e[0].name: Howdy Partner\n\n\n\n\nthen\n\n\nyaml w -s update_instructions.yaml sample.yaml\n\n\n\n\nwill output:\n\n\nb:\n c: 3\n e:\n - name: Howdy Partner\n\n\n\n\nAnd, of course, you can pipe the instructions in using '-':\n\n\ncat update_instructions.yaml | yaml w -s - sample.yaml\n\n\n\n\nValues starting with a hyphen (or dash)\n\n\nThe flag terminator needs to be used to stop the app from attempting to parse the subsequent arguments as flags:\n\n\nyaml w -- my.path -3\n\n\n\n\nwill output\n\n\nmy:\n path: -3\n\n\n\n\nKeys with dots\n\n\nWhen specifying a key that has a dot use key lookup indicator.\n\n\nb:\n foo.bar: 7\n\n\n\n\nyaml r sample.yaml b[foo.bar]\n\n\n\n\nyaml w sample.yaml b[foo.bar] 9\n\n\n\n\nAny valid yaml key can be specified as part of a key lookup.",
"title":"Write/Update"
},
{
"location":"/write/#to-stdout",
"text":"Given a sample.yaml file of: b:\n c: 2 then yaml w sample.yaml b.c cat will output: b:\n c: cat",
"title":"To Stdout"
},
{
"location":"/write/#from-stdin",
"text":"cat sample.yaml | yaml w - b.c blah",
"title":"From STDIN"
},
{
"location":"/write/#adding-new-fields",
"text":"Any missing fields in the path will be created on the fly. Given a sample.yaml file of: b:\n c: 2 then yaml w sample.yaml b.d[0] new thing will output: b:\n c: cat\n d:\n - new thing",
"text":"Given a sample.yaml file of: b:\n c: 2\n d:\n - new thing\n - foo thing then yaml w sample.yaml b.d[+] bar thing will output: b:\n c: cat\n d:\n - new thing\n - foo thing\n - bar thing",
"title":"Appending value to an array field"
},
{
"location":"/write/#updating-files-in-place",
"text":"Given a sample.yaml file of: b:\n c: 2 then yaml w -i sample.yaml b.c cat will update the sample.yaml file so that the value of 'c' is cat.",
"text":"Given a sample.yaml file of: b:\n c: 2\n e:\n - name: Billy Bob and a script update_instructions.yaml of: b.c: 3\nb.e[0].name: Howdy Partner then yaml w -s update_instructions.yaml sample.yaml will output: b:\n c: 3\n e:\n - name: Howdy Partner And, of course, you can pipe the instructions in using '-': cat update_instructions.yaml | yaml w -s - sample.yaml",
"text":"The flag terminator needs to be used to stop the app from attempting to parse the subsequent arguments as flags: yaml w -- my.path -3 will output my:\n path: -3",
"title":"Values starting with a hyphen (or dash)"
},
{
"location":"/write/#keys-with-dots",
"text":"When specifying a key that has a dot use key lookup indicator. b:\n foo.bar: 7 yaml r sample.yaml b[foo.bar] yaml w sample.yaml b[foo.bar] 9 Any valid yaml key can be specified as part of a key lookup.",
"title":"Keys with dots"
},
{
"location":"/create/",
"text":"Yaml files can be created using the 'new' command. This works in the same way as the write command, but you don't pass in an existing Yaml file.\n\n\nyaml n \npath\n \nnew value\n\n\n\n\n\nCreating a simple yaml file\n\n\nyaml n b.c cat\n\n\n\n\nwill output:\n\n\nb:\n c: cat\n\n\n\n\nCreating using a create script\n\n\nCreate scripts follow the same format as the update scripts.\n\n\nGiven a script create_instructions.yaml of:\n\n\nb.c: 3\nb.e[0].name: Howdy Partner\n\n\n\n\nthen\n\n\nyaml n -s create_instructions.yaml\n\n\n\n\nwill output:\n\n\nb:\n c: 3\n e:\n - name: Howdy Partner\n\n\n\n\nYou can also pipe the instructions in:\n\n\ncat create_instructions.yaml | yaml n -s -\n\n\n\n\nKeys with dots\n\n\nWhen specifying a key that has a dot use key lookup indicator.\n\n\nb:\n foo.bar: 7\n\n\n\n\nyaml r sample.yaml b[foo.bar]\n\n\n\n\nyaml w sample.yaml b[foo.bar] 9\n\n\n\n\nAny valid yaml key can be specified as part of a key lookup.",
"text":"Create scripts follow the same format as the update scripts. Given a script create_instructions.yaml of: b.c: 3\nb.e[0].name: Howdy Partner then yaml n -s create_instructions.yaml will output: b:\n c: 3\n e:\n - name: Howdy Partner You can also pipe the instructions in: cat create_instructions.yaml | yaml n -s -",
"title":"Creating using a create script"
},
{
"location":"/create/#keys-with-dots",
"text":"When specifying a key that has a dot use key lookup indicator. b:\n foo.bar: 7 yaml r sample.yaml b[foo.bar] yaml w sample.yaml b[foo.bar] 9 Any valid yaml key can be specified as part of a key lookup.",
"title":"Keys with dots"
},
{
"location":"/convert/",
"text":"Yaml to Json\n\n\nTo convert output to json, use the --tojson (or -j) flag. This can be used with any command.\n\n\nGiven a sample.yaml file of:\n\n\nb:\n c: 2\n\n\n\n\nthen\n\n\nyaml r -j sample.yaml b.c\n\n\n\n\nwill output\n\n\n{\nb\n:{\nc\n:2}}\n\n\n\n\nJson to Yaml\n\n\nTo read in json, just pass in a json file instead of yaml, it will just work :)\n\n\ne.g given a json file\n\n\n{\na\n:\nEasy! as one two three\n,\nb\n:{\nc\n:2,\nd\n:[3,4]}}\n\n\n\n\nthen\n\n\nyaml r sample.json\n\n\n\n\nwill output\n\n\na: Easy! as one two three\nb:\n c: 2\n d:\n - 3\n - 4",
"title":"Convert"
},
{
"location":"/convert/#yaml-to-json",
"text":"To convert output to json, use the --tojson (or -j) flag. This can be used with any command. Given a sample.yaml file of: b:\n c: 2 then yaml r -j sample.yaml b.c will output { b :{ c :2}}",
"title":"Yaml to Json"
},
{
"location":"/convert/#json-to-yaml",
"text":"To read in json, just pass in a json file instead of yaml, it will just work :) e.g given a json file { a : Easy! as one two three , b :{ c :2, d :[3,4]}} then yaml r sample.json will output a: Easy! as one two three\nb:\n c: 2\n d:\n - 3\n - 4",
"title":"Json to Yaml"
},
{
"location":"/merge/",
"text":"Yaml files can be merged using the 'merge' command. Each additional file merged with the first file will\nset values for any key not existing already or where the key has no value.\n\n\nyaml m \nyaml_file|json_file\n \npath\n...\n\n\n\n\nThis command can take a json file as input too, and will output yaml unless specified to export as json (-j)\n\n\nTo Stdout\n\n\nGiven a data1.yaml file of:\n\n\na: simple\nb: [1, 2]\n\n\n\n\nand data2.yaml file of:\n\n\na: other\nc:\n test: 1\n\n\n\n\nthen\n\n\nyaml m data1.yaml data2.yaml\n\n\n\n\nwill output:\n\n\na: simple\nb: [1, 2]\nc:\n test: 1\n\n\n\n\nUpdating files in-place\n\n\nGiven a data1.yaml file of:\n\n\na: simple\nb: [1, 2]\n\n\n\n\nand data2.yaml file of:\n\n\na: other\nc:\n test: 1\n\n\n\n\nthen\n\n\nyaml m -i data1.yaml data2.yaml\n\n\n\n\nwill update the data1.yaml file so that the value of 'c' is 'test: 1'.\n\n\nOverwrite values\n\n\nGiven a data1.yaml file of:\n\n\na: simple\nb: [1, 2]\n\n\n\n\nand data2.yaml file of:\n\n\na: other\nc:\n test: 1\n\n\n\n\nthen\n\n\nyaml m -x data1.yaml data2.yaml\n\n\n\n\nwill output:\n\n\na: other\nb: [1, 2]\nc:\n test: 1\n\n\n\n\nOverwrite values with arrays\n\n\nGiven a data1.yaml file of:\n\n\na: simple\nb: [1, 2]\n\n\n\n\nand data3.yaml file of:\n\n\nb: [2, 3, 4]\nc:\n test: 2\n other: true\nd: false\n\n\n\n\nthen\n\n\nyaml m -x data1.yaml data3.yaml\n\n\n\n\nwill output:\n\n\na: simple\nb: [2, 3, 4]\nc:\n test: 2\n other: true\nd: false\n\n\n\n\nNotice that 'b' does not result in the merging of the values within an array. The underlying library does not\ncurrently handle merging values within an array.",
"title":"Merge"
},
{
"location":"/merge/#to-stdout",
"text":"Given a data1.yaml file of: a: simple\nb: [1, 2] and data2.yaml file of: a: other\nc:\n test: 1 then yaml m data1.yaml data2.yaml will output: a: simple\nb: [1, 2]\nc:\n test: 1",
"title":"To Stdout"
},
{
"location":"/merge/#updating-files-in-place",
"text":"Given a data1.yaml file of: a: simple\nb: [1, 2] and data2.yaml file of: a: other\nc:\n test: 1 then yaml m -i data1.yaml data2.yaml will update the data1.yaml file so that the value of 'c' is 'test: 1'.",
"title":"Updating files in-place"
},
{
"location":"/merge/#overwrite-values",
"text":"Given a data1.yaml file of: a: simple\nb: [1, 2] and data2.yaml file of: a: other\nc:\n test: 1 then yaml m -x data1.yaml data2.yaml will output: a: other\nb: [1, 2]\nc:\n test: 1",
"text":"Given a data1.yaml file of: a: simple\nb: [1, 2] and data3.yaml file of: b: [2, 3, 4]\nc:\n test: 2\n other: true\nd: false then yaml m -x data1.yaml data3.yaml will output: a: simple\nb: [2, 3, 4]\nc:\n test: 2\n other: true\nd: false Notice that 'b' does not result in the merging of the values within an array. The underlying library does not\ncurrently handle merging values within an array.",
<pre><codeclass="bash">yaml r sample.yaml bob.*.cats
</code></pre>
<p>will output</p>
<pre><codeclass="yaml">- bananas
- apples
</code></pre>
<h3id="handling-in-the-yaml-key">Handling '.' in the yaml key<aclass="headerlink"href="#handling-in-the-yaml-key"title="Permanent link">¶</a></h3>
<p>Given a sample.yaml file of:</p>
<pre><codeclass="yaml">b.x:
c: 2
</code></pre>
<p>then</p>
<pre><codeclass="bash">yaml r sample.yaml \"b.x\".c
<pre><codeclass="bash">cat sample.yaml | yaml w - b.c blah
</code></pre>
<h3id="adding-new-fields">Adding new fields<aclass="headerlink"href="#adding-new-fields"title="Permanent link">¶</a></h3>
<p>Any missing fields in the path will be created on the fly.</p>
<p>Given a sample.yaml file of:</p>
<pre><codeclass="yaml">b:
c: 2
</code></pre>
<p>then</p>
<pre><codeclass="bash">yaml w sample.yaml b.d[0] "new thing"
</code></pre>
<p>will output:</p>
<pre><codeclass="yaml">b:
c: cat
d:
- new thing
</code></pre>
<h3id="appending-value-to-an-array-field">Appending value to an array field<aclass="headerlink"href="#appending-value-to-an-array-field"title="Permanent link">¶</a></h3>
<p>Given a sample.yaml file of:</p>
<pre><codeclass="yaml">b:
c: 2
d:
- new thing
- foo thing
</code></pre>
<p>then</p>
<pre><codeclass="bash">yaml w sample.yaml b.d[+] "bar thing"
<pre><codeclass="bash">yaml w -i sample.yaml b.c cat
</code></pre>
<p>will update the sample.yaml file so that the value of 'c' is cat.</p>
<h3id="updating-multiple-values-with-a-script">Updating multiple values with a script<aclass="headerlink"href="#updating-multiple-values-with-a-script"title="Permanent link">¶</a></h3>
<p>Given a sample.yaml file of:</p>
<pre><codeclass="yaml">b:
c: 2
e:
- name: Billy Bob
</code></pre>
<p>and a script update_instructions.yaml of:</p>
<pre><codeclass="yaml">b.c: 3
b.e[0].name: Howdy Partner
</code></pre>
<p>then</p>
<pre><codeclass="bash">yaml w -s update_instructions.yaml sample.yaml
</code></pre>
<p>will output:</p>
<pre><codeclass="yaml">b:
c: 3
e:
- name: Howdy Partner
</code></pre>
<p>And, of course, you can pipe the instructions in using '-':</p>
<pre><codeclass="bash">cat update_instructions.yaml | yaml w -s - sample.yaml
</code></pre>
<h3id="values-starting-with-a-hyphen-or-dash">Values starting with a hyphen (or dash)<aclass="headerlink"href="#values-starting-with-a-hyphen-or-dash"title="Permanent link">¶</a></h3>
<p>The flag terminator needs to be used to stop the app from attempting to parse the subsequent arguments as flags:</p>
<pre><code>yaml w -- my.path -3
</code></pre>
<p>will output</p>
<pre><codeclass="yaml">my:
path: -3
</code></pre>
<h3id="keys-with-dots">Keys with dots<aclass="headerlink"href="#keys-with-dots"title="Permanent link">¶</a></h3>
<p>When specifying a key that has a dot use key lookup indicator.</p>
<pre><codeclass="yaml">b:
foo.bar: 7
</code></pre>
<pre><codeclass="bash">yaml r sample.yaml b[foo.bar]
</code></pre>
<pre><codeclass="bash">yaml w sample.yaml b[foo.bar] 9
</code></pre>
<p>Any valid yaml key can be specified as part of a key lookup.</p>
Some files were not shown because too many files have changed in this diff
Show More
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.