Updating README with latest yq help

This commit is contained in:
Mike Farah 2025-11-22 15:04:39 +11:00
parent 810e9d921e
commit fc164ca9c3
2 changed files with 57 additions and 46 deletions

View File

@ -380,10 +380,18 @@ Usage:
Examples: Examples:
# yq defaults to 'eval' command if no command is specified. See "yq eval --help" for more examples. # yq tries to auto-detect the file format based off the extension, and defaults to YAML if it's unknown (or piping through STDIN)
yq '.stuff' < myfile.yml # outputs the data at the "stuff" node from "myfile.yml" # Use the '-p/--input-format' flag to specify a format type.
cat file.xml | yq -p xml
yq -i '.stuff = "foo"' myfile.yml # update myfile.yml in place # read the "stuff" node from "myfile.yml"
yq '.stuff' < myfile.yml
# update myfile.yml in place
yq -i '.stuff = "foo"' myfile.yml
# print contents of sample.json as idiomatic YAML
yq -P -oy sample.json
Available Commands: Available Commands:
@ -393,46 +401,51 @@ Available Commands:
help Help about any command help Help about any command
Flags: Flags:
-C, --colors force print with colors -C, --colors force print with colors
--csv-auto-parse parse CSV YAML/JSON values (default true) --csv-auto-parse parse CSV YAML/JSON values (default true)
--csv-separator char CSV Separator character (default ,) --csv-separator char CSV Separator character (default ,)
-e, --exit-status set exit status if there are no matches or null or false is returned --debug-node-info debug node info
--expression string forcibly set the expression argument. Useful when yq argument detection thinks your expression is a file. -e, --exit-status set exit status if there are no matches or null or false is returned
--from-file string Load expression from specified file. --expression string forcibly set the expression argument. Useful when yq argument detection thinks your expression is a 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 --from-file string Load expression from specified file.
--header-preprocess Slurp any header comments and separators before processing expression. (default true) -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
-h, --help help for yq --header-preprocess Slurp any header comments and separators before processing expression. (default true)
-I, --indent int sets indent level for output (default 2) -h, --help help for yq
-i, --inplace update the file in place of first file given. -I, --indent int sets indent level for output (default 2)
-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") -i, --inplace update the file in place of first file given.
--lua-globals output keys as top-level global variables -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-prefix string prefix (default "return ") --lua-globals output keys as top-level global variables
--lua-suffix string suffix (default ";\n") --lua-prefix string prefix (default "return ")
--lua-unquoted output unquoted string keys (e.g. {foo="bar"}) --lua-suffix string suffix (default ";\n")
-M, --no-colors force print with no colors --lua-unquoted output unquoted string keys (e.g. {foo="bar"})
-N, --no-doc Don't print document separators (---) -M, --no-colors force print with no colors
-0, --nul-output Use NUL char to separate values. If unwrap scalar is also set, fail if unwrapped scalar contains NUL char. -N, --no-doc Don't print document separators (---)
-n, --null-input Don't read input, simply evaluate the expression given. Useful for creating docs from scratch. -0, --nul-output Use NUL char to separate values. If unwrap scalar is also set, fail if unwrapped scalar contains NUL char.
-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") -n, --null-input Don't read input, simply evaluate the expression given. Useful for creating docs from scratch.
-P, --prettyPrint pretty print, shorthand for '... style = ""' -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")
--properties-array-brackets use [x] in array paths (e.g. for SpringBoot) -P, --prettyPrint pretty print, shorthand for '... style = ""'
--properties-separator string separator to use between keys and values (default " = ") --properties-array-brackets use [x] in array paths (e.g. for SpringBoot)
-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. --properties-separator string separator to use between keys and values (default " = ")
--split-exp-file string Use a file to specify the split-exp expression. --security-disable-env-ops Disable env related operations.
--string-interpolation Toggles strings interpolation of \(exp) (default true) --security-disable-file-ops Disable file related operations (e.g. load)
--tsv-auto-parse parse TSV YAML/JSON values (default true) --shell-key-separator string separator for shell variable key paths (default "_")
-r, --unwrapScalar unwrap scalar, print the value with no quotes, colors or comments. Defaults to true for yaml (default true) -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.
-v, --verbose verbose mode --split-exp-file string Use a file to specify the split-exp expression.
-V, --version Print version information and quit --string-interpolation Toggles strings interpolation of \(exp) (default true)
--xml-attribute-prefix string prefix for xml attributes (default "+@") --tsv-auto-parse parse TSV YAML/JSON values (default true)
--xml-content-name string name for xml content (if no attribute name is present). (default "+content") -r, --unwrapScalar unwrap scalar, print the value with no quotes, colors or comments. Defaults to true for yaml (default true)
--xml-directive-name string name for xml directives (e.g. <!DOCTYPE thing cat>) (default "+directive") -v, --verbose verbose mode
--xml-keep-namespace enables keeping namespace after parsing attributes (default true) -V, --version Print version information and quit
--xml-proc-inst-prefix string prefix for xml processing instructions (e.g. <?xml version="1"?>) (default "+p_") --xml-attribute-prefix string prefix for xml attributes (default "+@")
--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-content-name string name for xml content (if no attribute name is present). (default "+content")
--xml-skip-directives skip over directives (e.g. <!DOCTYPE thing cat>) --xml-directive-name string name for xml directives (e.g. <!DOCTYPE thing cat>) (default "+directive")
--xml-skip-proc-inst skip over process instructions (e.g. <?xml version="1"?>) --xml-keep-namespace enables keeping namespace after parsing attributes (default true)
--xml-strict-mode enables strict parsing of XML. See https://pkg.go.dev/encoding/xml for more details. --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.
--yaml-fix-merge-anchor-to-spec Fix merge anchor to match YAML spec. Will default to true in late 2025
Use "yq [command] --help" for more information about a command. Use "yq [command] --help" for more information about a command.
``` ```

View File

@ -1,3 +1 @@
[[fruits]] a: apple
[[fruits.varieties]] # nested array of tables
name = "red delicious