1
0
mirror of https://github.com/taigrr/yq synced 2025-01-18 04:53:17 -08:00

Rename to yq

This commit is contained in:
Mike Farah
2017-12-18 09:11:08 +11:00
parent dc4f8a6adb
commit cb48ba7173
15 changed files with 81 additions and 79 deletions

View File

@@ -8,7 +8,7 @@ b:
```
then
```bash
yaml r -j sample.yaml b.c
yq r -j sample.yaml b.c
```
will output
@@ -26,7 +26,7 @@ e.g given a json file
```
then
```bash
yaml r sample.json
yq r sample.json
```
will output
```yaml

View File

@@ -1,12 +1,12 @@
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.
```
yaml n <path> <new value>
yq n <path> <new value>
```
### Creating a simple yaml file
```bash
yaml n b.c cat
yq n b.c cat
```
will output:
```yaml
@@ -25,7 +25,7 @@ b.e[0].name: Howdy Partner
then
```bash
yaml n -s create_instructions.yaml
yq n -s create_instructions.yaml
```
will output:
```yaml
@@ -38,7 +38,7 @@ b:
You can also pipe the instructions in:
```bash
cat create_instructions.yaml | yaml n -s -
cat create_instructions.yaml | yq n -s -
```
{!snippets/keys_with_dots.md!}

View File

@@ -1,5 +1,5 @@
# yaml
yaml is a lightweight and portable command-line YAML processor
# yq
yq is a lightweight and portable command-line YAML processor
The aim of the project is to be the [jq](https://github.com/stedolan/jq) or sed of yaml files.
@@ -7,10 +7,10 @@ The aim of the project is to be the [jq](https://github.com/stedolan/jq) or sed
### get the source
```bash
go get github.com/mikefarah/yaml
go get github.com/mikefarah/yq
```
[.zip](https://github.com/mikefarah/yaml/zipball/master) or [tar.gz](https://github.com/mikefarah/yaml/tarball/master)
[.zip](https://github.com/mikefarah/yq/zipball/master) or [tar.gz](https://github.com/mikefarah/yq/tarball/master)
[View on GitHub](https://github.com/mikefarah/yaml)
[View on GitHub](https://github.com/mikefarah/yq)

View File

@@ -2,7 +2,7 @@ Yaml files can be merged using the 'merge' command. Each additional file merged
set values for any key not existing already or where the key has no value.
```
yaml m <yaml_file|json_file> <path>...
yq m <yaml_file|json_file> <path>...
```
{!snippets/works_with_json.md!}
@@ -20,7 +20,7 @@ c:
```
then
```bash
yaml m data1.yaml data2.yaml
yq m data1.yaml data2.yaml
```
will output:
```yaml
@@ -44,7 +44,7 @@ c:
```
then
```bash
yaml m -i data1.yaml data2.yaml
yq m -i data1.yaml data2.yaml
```
will update the data1.yaml file so that the value of 'c' is 'test: 1'.
@@ -62,7 +62,7 @@ c:
```
then
```bash
yaml m -x data1.yaml data2.yaml
yq m -x data1.yaml data2.yaml
```
will output:
```yaml
@@ -88,7 +88,7 @@ d: false
```
then
```bash
yaml m -x data1.yaml data3.yaml
yq m -x data1.yaml data3.yaml
```
will output:
```yaml

View File

@@ -1,5 +1,5 @@
```
yaml r <yaml_file|json_file> <path>
yq r <yaml_file|json_file> <path>
```
{!snippets/works_with_json.md!}
@@ -12,14 +12,14 @@ b:
```
then
```bash
yaml r sample.yaml b.c
yq r sample.yaml b.c
```
will output the value of '2'.
### From Stdin
Given a sample.yaml file of:
```bash
cat sample.yaml | yaml r - b.c
cat sample.yaml | yq r - b.c
```
will output the value of '2'.
@@ -35,7 +35,7 @@ bob:
```
then
```bash
yaml r sample.yaml bob.*.cats
yq r sample.yaml bob.*.cats
```
will output
```yaml
@@ -51,7 +51,7 @@ b.x:
```
then
```bash
yaml r sample.yaml \"b.x\".c
yq r sample.yaml \"b.x\".c
```
will output the value of '2'.
@@ -68,7 +68,7 @@ b:
```
then
```
yaml r sample.yaml b.e[1].name
yq r sample.yaml b.e[1].name
```
will output 'sam'
@@ -84,7 +84,7 @@ b:
```
then
```
yaml r sample.yaml b.e[*].name
yq r sample.yaml b.e[*].name
```
will output:
```

View File

@@ -1,5 +1,5 @@
```
yaml w <yaml_file|json_file> <path> <new value>
yq w <yaml_file|json_file> <path> <new value>
```
{!snippets/works_with_json.md!}
@@ -11,7 +11,7 @@ b:
```
then
```bash
yaml w sample.yaml b.c cat
yq w sample.yaml b.c cat
```
will output:
```yaml
@@ -21,7 +21,7 @@ b:
### From STDIN
```bash
cat sample.yaml | yaml w - b.c blah
cat sample.yaml | yq w - b.c blah
```
### Adding new fields
@@ -34,7 +34,7 @@ b:
```
then
```bash
yaml w sample.yaml b.d[0] "new thing"
yq w sample.yaml b.d[0] "new thing"
```
will output:
```yaml
@@ -55,7 +55,7 @@ b:
```
then
```bash
yaml w sample.yaml b.d[+] "bar thing"
yq w sample.yaml b.d[+] "bar thing"
```
will output:
```yaml
@@ -75,7 +75,7 @@ b:
```
then
```bash
yaml w -i sample.yaml b.c cat
yq w -i sample.yaml b.c cat
```
will update the sample.yaml file so that the value of 'c' is cat.
@@ -96,7 +96,7 @@ b.e[0].name: Howdy Partner
then
```bash
yaml w -s update_instructions.yaml sample.yaml
yq w -s update_instructions.yaml sample.yaml
```
will output:
```yaml
@@ -108,14 +108,14 @@ b:
And, of course, you can pipe the instructions in using '-':
```bash
cat update_instructions.yaml | yaml w -s - sample.yaml
cat update_instructions.yaml | yq w -s - sample.yaml
```
### Values starting with a hyphen (or dash)
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
yq w -- my.path -3
```
will output