mirror of
https://github.com/taigrr/yq
synced 2025-01-18 04:53:17 -08:00
Compare commits
150 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d84254c30f | ||
|
|
18bb4eee96 | ||
|
|
86b9fe3ef9 | ||
|
|
2c15048ddb | ||
|
|
ce2ee42f71 | ||
|
|
c2c49dcb17 | ||
|
|
60de18391c | ||
|
|
c86f8b426b | ||
|
|
b3532e0a61 | ||
|
|
b3b60665e4 | ||
|
|
df08b055cf | ||
|
|
e822313e82 | ||
|
|
a9f25c9d76 | ||
|
|
0a8c268dcc | ||
|
|
a0e70279a8 | ||
|
|
25c9c22d8d | ||
|
|
d46d555b07 | ||
|
|
fb87f638f2 | ||
|
|
facc81d1f4 | ||
|
|
c1f9065c68 | ||
|
|
be84cc3082 | ||
|
|
a2571da1a1 | ||
|
|
6d6e476ac8 | ||
|
|
ae0c042ae6 | ||
|
|
867ec92d3a | ||
|
|
113586b5e0 | ||
|
|
c38f19e0a9 | ||
|
|
8ca85b1c64 | ||
|
|
08870f8ec9 | ||
|
|
94b217984c | ||
|
|
2f5a481cc3 | ||
|
|
1a4064429d | ||
|
|
1b22e1d812 | ||
|
|
297522cbdd | ||
|
|
be991fdacd | ||
|
|
be08214773 | ||
|
|
9e971ebeae | ||
|
|
f340db5795 | ||
|
|
ab852ceafa | ||
|
|
06a843e9b2 | ||
|
|
ebdc092688 | ||
|
|
27089d1ca1 | ||
|
|
1853585d22 | ||
|
|
0124d26086 | ||
|
|
0d68bea3dc | ||
|
|
54603b3607 | ||
|
|
c86aeca325 | ||
|
|
a4f124f24f | ||
|
|
090b377fa5 | ||
|
|
3a4d62d820 | ||
|
|
6053c8c136 | ||
|
|
c5a45ba7d5 | ||
|
|
56a0771cd1 | ||
|
|
8072e66d46 | ||
|
|
26153b3eb5 | ||
|
|
f2e10f21c7 | ||
|
|
d3ecf7aa88 | ||
|
|
ee8ffd458a | ||
|
|
8f15dba812 | ||
|
|
92ce195424 | ||
|
|
e725a2cec5 | ||
|
|
37de7a3505 | ||
|
|
e96794a420 | ||
|
|
120ef8e4dc | ||
|
|
db1954da25 | ||
|
|
e552dbb6ab | ||
|
|
298126864f | ||
|
|
d30cd8cc75 | ||
|
|
e6ee86930b | ||
|
|
0ea3c71df7 | ||
|
|
ef99bedf45 | ||
|
|
6e1a5aef2c | ||
|
|
70bd860287 | ||
|
|
0abda0098c | ||
|
|
a409a7e82b | ||
|
|
0e4f9e8579 | ||
|
|
0c932ba7dc | ||
|
|
cb48ba7173 | ||
|
|
dc4f8a6adb | ||
|
|
1f6d7a50b2 | ||
|
|
6fc3bdf58f | ||
|
|
87b33e8603 | ||
|
|
cc7eb84388 | ||
|
|
9e3f8ebd0a | ||
|
|
28bcbd321f | ||
|
|
9dd4503b23 | ||
|
|
185d1faadb | ||
|
|
7b004cb456 | ||
|
|
54c73eb34f | ||
|
|
3b03a0852a | ||
|
|
a00e6c5316 | ||
|
|
9d1a5b17b8 | ||
|
|
c5f80a105d | ||
|
|
c17f8df8f8 | ||
|
|
66c8390d54 | ||
|
|
dda9b1f087 | ||
|
|
683de28c64 | ||
|
|
51fa1a87b7 | ||
|
|
b9ac6a3d9d | ||
|
|
499974c27e | ||
|
|
72bd88cfa5 | ||
|
|
6980be3800 | ||
|
|
2933ea1684 | ||
|
|
cf2f23d747 | ||
|
|
45e9ad870f | ||
|
|
53b2c64747 | ||
|
|
359ca5a117 | ||
|
|
79baa49eaa | ||
|
|
2cda78ce0b | ||
|
|
6d1e61c410 | ||
|
|
86639acf70 | ||
|
|
3beee3f804 | ||
|
|
1ed8e7017e | ||
|
|
5514d2300b | ||
|
|
5bb0934710 | ||
|
|
cdd78af4bc | ||
|
|
d07e436065 | ||
|
|
b2a0964de2 | ||
|
|
69e6bb354d | ||
|
|
ec25886528 | ||
|
|
c2000a446b | ||
|
|
08ba0083be | ||
|
|
909b62be54 | ||
|
|
0facf35d60 | ||
|
|
a7c4813703 | ||
|
|
373e0a5eb7 | ||
|
|
124c57f9d9 | ||
|
|
fb73a793bd | ||
|
|
c22394b540 | ||
|
|
b1ff47022b | ||
|
|
82f1230db8 | ||
|
|
a3190f1504 | ||
|
|
44ee869e47 | ||
|
|
5d2d37a5f8 | ||
|
|
e3fc944709 | ||
|
|
6ee9db9a70 | ||
|
|
0d75edfb67 | ||
|
|
037314af8a | ||
|
|
2a283b4ef7 | ||
|
|
7ef556f22b | ||
|
|
6b566fd983 | ||
|
|
001925a4d4 | ||
|
|
3dee7b89d2 | ||
|
|
c955815aab | ||
|
|
3720bf8211 | ||
|
|
5f09aabf4c | ||
|
|
98751cf607 | ||
|
|
2ec3b59da2 | ||
|
|
56c923228d | ||
|
|
c122b9a843 |
13
.gitignore
vendored
13
.gitignore
vendored
@@ -6,6 +6,7 @@
|
|||||||
# Folders
|
# Folders
|
||||||
_obj
|
_obj
|
||||||
_test
|
_test
|
||||||
|
bin
|
||||||
build
|
build
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
|
||||||
@@ -20,8 +21,18 @@ _cgo_gotypes.go
|
|||||||
_cgo_export.*
|
_cgo_export.*
|
||||||
|
|
||||||
_testmain.go
|
_testmain.go
|
||||||
|
coverage.out
|
||||||
*.exe
|
*.exe
|
||||||
*.test
|
*.test
|
||||||
*.prof
|
*.prof
|
||||||
yaml
|
yaml
|
||||||
|
vendor/*/
|
||||||
|
tmp/
|
||||||
|
cover/
|
||||||
|
yq
|
||||||
|
|
||||||
|
# snapcraft
|
||||||
|
parts/
|
||||||
|
prime/
|
||||||
|
.snapcraft/
|
||||||
|
yq*.snap
|
||||||
|
|||||||
6
.travis.yml
Normal file
6
.travis.yml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
language: go
|
||||||
|
go:
|
||||||
|
- 1.9.x
|
||||||
|
script:
|
||||||
|
- scripts/devtools.sh
|
||||||
|
- make local build
|
||||||
24
Dockerfile
Normal file
24
Dockerfile
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
FROM golang:1.9 as builder
|
||||||
|
|
||||||
|
WORKDIR /go/src/mikefarah/yq
|
||||||
|
|
||||||
|
# cache devtools
|
||||||
|
COPY ./scripts/devtools.sh /go/src/mikefarah/yq/scripts/devtools.sh
|
||||||
|
RUN ./scripts/devtools.sh
|
||||||
|
|
||||||
|
# cache vendor
|
||||||
|
COPY ./vendor/vendor.json /go/src/mikefarah/yq/vendor/vendor.json
|
||||||
|
RUN govendor sync
|
||||||
|
|
||||||
|
COPY . /go/src/mikefarah/yq
|
||||||
|
|
||||||
|
RUN CGO_ENABLED=0 make local build
|
||||||
|
|
||||||
|
# Choose alpine as a base image to make this useful for CI, as many
|
||||||
|
# CI tools expect an interactive shell inside the container
|
||||||
|
FROM alpine:3.7
|
||||||
|
|
||||||
|
COPY --from=builder /go/src/mikefarah/yq/yq /usr/bin/yq
|
||||||
|
RUN chmod +x /usr/bin/yq
|
||||||
|
|
||||||
|
WORKDIR /workdir
|
||||||
30
Dockerfile.dev
Normal file
30
Dockerfile.dev
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
FROM golang:1.9
|
||||||
|
|
||||||
|
COPY scripts/devtools.sh /opt/devtools.sh
|
||||||
|
|
||||||
|
RUN set -e -x \
|
||||||
|
&& /opt/devtools.sh
|
||||||
|
|
||||||
|
# install mkdocs
|
||||||
|
RUN set -ex \
|
||||||
|
&& buildDeps=' \
|
||||||
|
build-essential \
|
||||||
|
python-dev \
|
||||||
|
' \
|
||||||
|
&& apt-get update && apt-get install -y --no-install-recommends \
|
||||||
|
$buildDeps \
|
||||||
|
python2.7 \
|
||||||
|
python-setuptools \
|
||||||
|
python-wheel \
|
||||||
|
python-pip \
|
||||||
|
&& pip install --upgrade \
|
||||||
|
pip \
|
||||||
|
'Markdown>=2.6.9' \
|
||||||
|
'mkdocs>=0.16.3' \
|
||||||
|
'mkdocs-material>=1.10.1' \
|
||||||
|
'markdown-include>=0.5.1' \
|
||||||
|
&& apt-get purge -y --auto-remove $buildDeps \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
ENV CGO_ENABLED 0
|
||||||
|
ENV GOPATH /go:/yq
|
||||||
19
LICENSE
Normal file
19
LICENSE
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
Copyright (c) 2017 Mike Farah
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
120
Makefile
Normal file
120
Makefile
Normal file
@@ -0,0 +1,120 @@
|
|||||||
|
MAKEFLAGS += --warn-undefined-variables
|
||||||
|
SHELL := /bin/bash
|
||||||
|
.SHELLFLAGS := -o pipefail -euc
|
||||||
|
.DEFAULT_GOAL := install
|
||||||
|
|
||||||
|
include Makefile.variables
|
||||||
|
|
||||||
|
.PHONY: help
|
||||||
|
help:
|
||||||
|
@echo 'Management commands for cicdtest:'
|
||||||
|
@echo
|
||||||
|
@echo 'Usage:'
|
||||||
|
@echo ' ## Develop / Test Commands'
|
||||||
|
@echo ' make build Build yq binary.'
|
||||||
|
@echo ' make install Install yq.'
|
||||||
|
@echo ' make xcompile Build cross-compiled binaries of yq.'
|
||||||
|
@echo ' make snap Build a snap package of yq.'
|
||||||
|
@echo ' make vendor Install dependencies using govendor.'
|
||||||
|
@echo ' make format Run code formatter.'
|
||||||
|
@echo ' make check Run static code analysis (lint).'
|
||||||
|
@echo ' make test Run tests on project.'
|
||||||
|
@echo ' make cover Run tests and capture code coverage metrics on project.'
|
||||||
|
@echo ' make clean Clean the directory tree of produced artifacts.'
|
||||||
|
@echo
|
||||||
|
@echo ' ## Utility Commands'
|
||||||
|
@echo ' make setup Configures Minishfit/Docker directory mounts.'
|
||||||
|
@echo
|
||||||
|
|
||||||
|
|
||||||
|
.PHONY: clean
|
||||||
|
clean:
|
||||||
|
@rm -rf bin build cover *.out
|
||||||
|
|
||||||
|
## prefix before other make targets to run in your local dev environment
|
||||||
|
local: | quiet
|
||||||
|
@$(eval DOCKRUN= )
|
||||||
|
@mkdir -p tmp
|
||||||
|
@touch tmp/dev_image_id
|
||||||
|
quiet: # this is silly but shuts up 'Nothing to be done for `local`'
|
||||||
|
@:
|
||||||
|
|
||||||
|
prepare: tmp/dev_image_id
|
||||||
|
tmp/dev_image_id: Dockerfile.dev scripts/devtools.sh
|
||||||
|
@mkdir -p tmp
|
||||||
|
@docker rmi -f ${DEV_IMAGE} > /dev/null 2>&1 || true
|
||||||
|
@docker build -t ${DEV_IMAGE} -f Dockerfile.dev .
|
||||||
|
@docker inspect -f "{{ .ID }}" ${DEV_IMAGE} > tmp/dev_image_id
|
||||||
|
|
||||||
|
# ----------------------------------------------
|
||||||
|
# build
|
||||||
|
.PHONY: build
|
||||||
|
build: build/dev
|
||||||
|
|
||||||
|
.PHONY: build/dev
|
||||||
|
build/dev: test *.go
|
||||||
|
@mkdir -p bin/
|
||||||
|
${DOCKRUN} go build --ldflags "$(LDFLAGS)"
|
||||||
|
${DOCKRUN} bash ./scripts/acceptance.sh
|
||||||
|
|
||||||
|
## Compile the project for multiple OS and Architectures.
|
||||||
|
xcompile: check
|
||||||
|
@rm -rf build/
|
||||||
|
@mkdir -p build
|
||||||
|
${DOCKRUN} bash ./scripts/xcompile.sh
|
||||||
|
@find build -type d -exec chmod 755 {} \; || :
|
||||||
|
@find build -type f -exec chmod 755 {} \; || :
|
||||||
|
|
||||||
|
.PHONY: snap
|
||||||
|
snap:
|
||||||
|
snapcraft
|
||||||
|
|
||||||
|
.PHONY: install
|
||||||
|
install: build
|
||||||
|
${DOCKRUN} go install
|
||||||
|
|
||||||
|
# Each of the fetch should be an entry within vendor.json; not currently included within project
|
||||||
|
.PHONY: vendor
|
||||||
|
vendor: tmp/dev_image_id
|
||||||
|
${DOCKRUN} govendor sync
|
||||||
|
@chmod 664 vendor/vendor.json
|
||||||
|
|
||||||
|
# ----------------------------------------------
|
||||||
|
# develop and test
|
||||||
|
|
||||||
|
.PHONY: format
|
||||||
|
format: vendor
|
||||||
|
${DOCKRUN} bash ./scripts/format.sh
|
||||||
|
|
||||||
|
.PHONY: check
|
||||||
|
check: format
|
||||||
|
${DOCKRUN} bash ./scripts/check.sh
|
||||||
|
|
||||||
|
.PHONY: test
|
||||||
|
test: check
|
||||||
|
${DOCKRUN} bash ./scripts/test.sh
|
||||||
|
|
||||||
|
.PHONY: cover
|
||||||
|
cover: check
|
||||||
|
@rm -rf cover/
|
||||||
|
@mkdir -p cover
|
||||||
|
${DOCKRUN} bash ./scripts/coverage.sh
|
||||||
|
@find cover -type d -exec chmod 755 {} \; || :
|
||||||
|
@find cover -type f -exec chmod 644 {} \; || :
|
||||||
|
|
||||||
|
.PHONY: build-docs
|
||||||
|
build-docs: prepare mkdocs.yml mkdocs/*
|
||||||
|
${DOCKRUN} mkdocs build
|
||||||
|
@find docs -type d -exec chmod 755 {} \; || :
|
||||||
|
@find docs -type f -exec chmod 644 {} \; || :
|
||||||
|
|
||||||
|
.PHONY: release
|
||||||
|
release: xcompile
|
||||||
|
${DOCKRUN} bash ./scripts/publish.sh
|
||||||
|
|
||||||
|
# ----------------------------------------------
|
||||||
|
# utilities
|
||||||
|
|
||||||
|
.PHONY: setup
|
||||||
|
setup:
|
||||||
|
@bash ./scripts/setup.sh
|
||||||
38
Makefile.variables
Normal file
38
Makefile.variables
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
export PROJECT = yq
|
||||||
|
IMPORT_PATH := github.com/mikefarah/${PROJECT}
|
||||||
|
|
||||||
|
export GIT_COMMIT = $(shell git rev-parse --short HEAD)
|
||||||
|
export GIT_DIRTY = $(shell test -n "$$(git status --porcelain)" && echo "+CHANGES" || true)
|
||||||
|
export GIT_DESCRIBE = $(shell git describe --tags --always)
|
||||||
|
LDFLAGS :=
|
||||||
|
LDFLAGS += -X main.GitCommit=${GIT_COMMIT}${GIT_DIRTY}
|
||||||
|
LDFLAGS += -X main.GitDescribe=${GIT_DESCRIBE}
|
||||||
|
|
||||||
|
GITHUB_TOKEN ?=
|
||||||
|
|
||||||
|
# Windows environment?
|
||||||
|
CYG_CHECK := $(shell hash cygpath 2>/dev/null && echo 1)
|
||||||
|
ifeq ($(CYG_CHECK),1)
|
||||||
|
VBOX_CHECK := $(shell hash VBoxManage 2>/dev/null && echo 1)
|
||||||
|
|
||||||
|
# Docker Toolbox (pre-Windows 10)
|
||||||
|
ifeq ($(VBOX_CHECK),1)
|
||||||
|
ROOT := /${PROJECT}
|
||||||
|
else
|
||||||
|
# Docker Windows
|
||||||
|
ROOT := $(shell cygpath -m -a "$(shell pwd)")
|
||||||
|
endif
|
||||||
|
else
|
||||||
|
# all non-windows environments
|
||||||
|
ROOT := $(shell pwd)
|
||||||
|
endif
|
||||||
|
|
||||||
|
DEV_IMAGE := ${PROJECT}_dev
|
||||||
|
|
||||||
|
DOCKRUN := docker run --rm \
|
||||||
|
-e LDFLAGS="${LDFLAGS}" \
|
||||||
|
-e GITHUB_TOKEN="${GITHUB_TOKEN}" \
|
||||||
|
-v ${ROOT}/vendor:/go/src \
|
||||||
|
-v ${ROOT}:/${PROJECT}/src/${IMPORT_PATH} \
|
||||||
|
-w /${PROJECT}/src/${IMPORT_PATH} \
|
||||||
|
${DEV_IMAGE}
|
||||||
232
README.md
232
README.md
@@ -1,162 +1,90 @@
|
|||||||
# yaml
|
# yq [](https://travis-ci.org/mikefarah/yq)
|
||||||
yaml is portable command line tool written in go
|
a lightweight and portable command-line YAML processor
|
||||||
|
|
||||||
Allows you to read and update yaml files from bash (or whatever). All in a lovely dependency free binary!
|
The aim of the project is to be the [jq](https://github.com/stedolan/jq) or sed of yaml files.
|
||||||
|
|
||||||
[Download latest release](https://github.com/mikefarah/yaml/releases/latest)
|
## Install
|
||||||
|
On MacOS:
|
||||||
or alternatively install using go get:
|
|
||||||
```
|
```
|
||||||
go get github.com/mikefarah/yaml
|
brew install yq
|
||||||
|
```
|
||||||
|
On Ubuntu and other Linux distros supporting `snap` packages:
|
||||||
|
```
|
||||||
|
snap install yq
|
||||||
|
```
|
||||||
|
On Ubuntu 16.04 or higher from Debian package:
|
||||||
|
```
|
||||||
|
sudo add-apt-repository ppa:rmescandon/yq
|
||||||
|
sudo apt update
|
||||||
|
sudo apt install yq -y
|
||||||
|
```
|
||||||
|
or, [Download latest binary](https://github.com/mikefarah/yq/releases/latest) or alternatively:
|
||||||
|
```
|
||||||
|
go get gopkg.in/mikefarah/yq.v2
|
||||||
```
|
```
|
||||||
|
|
||||||
## Read examples
|
## Run with Docker
|
||||||
```
|
|
||||||
yaml r <yaml file> <path>
|
|
||||||
```
|
|
||||||
|
|
||||||
### Basic
|
Oneshot use:
|
||||||
Given a sample.yaml file of:
|
|
||||||
```yaml
|
|
||||||
b:
|
|
||||||
c: 2
|
|
||||||
```
|
|
||||||
then
|
|
||||||
```bash
|
|
||||||
yaml r sample.yaml b.c
|
|
||||||
```
|
|
||||||
will output the value of '2'.
|
|
||||||
|
|
||||||
### Reading from STDIN
|
|
||||||
Given a sample.yaml file of:
|
|
||||||
```bash
|
|
||||||
cat sample.yaml | yaml r - b.c
|
|
||||||
```
|
|
||||||
will output the value of '2'.
|
|
||||||
|
|
||||||
### Splat
|
|
||||||
Given a sample.yaml file of:
|
|
||||||
```yaml
|
|
||||||
---
|
|
||||||
bob:
|
|
||||||
item1:
|
|
||||||
cats: bananas
|
|
||||||
item2:
|
|
||||||
cats: apples
|
|
||||||
```
|
|
||||||
then
|
|
||||||
```bash
|
|
||||||
yaml r sample.yaml bob.*.cats
|
|
||||||
```
|
|
||||||
will output
|
|
||||||
```yaml
|
|
||||||
- bananas
|
|
||||||
- apples
|
|
||||||
```
|
|
||||||
|
|
||||||
### Handling '.' in the yaml key
|
|
||||||
Given a sample.yaml file of:
|
|
||||||
```yaml
|
|
||||||
b.x:
|
|
||||||
c: 2
|
|
||||||
```
|
|
||||||
then
|
|
||||||
```bash
|
|
||||||
yaml r sample.yaml \"b.x\".c
|
|
||||||
```
|
|
||||||
will output the value of '2'.
|
|
||||||
|
|
||||||
### Arrays
|
|
||||||
You can give an index to access a specific element:
|
|
||||||
e.g.: given a sample file of
|
|
||||||
```yaml
|
|
||||||
b:
|
|
||||||
e:
|
|
||||||
- name: fred
|
|
||||||
value: 3
|
|
||||||
- name: sam
|
|
||||||
value: 4
|
|
||||||
```
|
|
||||||
then
|
|
||||||
```
|
|
||||||
yaml r sample.yaml b.e[1].name
|
|
||||||
```
|
|
||||||
will output 'sam'
|
|
||||||
|
|
||||||
### Array Splat
|
|
||||||
e.g.: given a sample file of
|
|
||||||
```yaml
|
|
||||||
b:
|
|
||||||
e:
|
|
||||||
- name: fred
|
|
||||||
value: 3
|
|
||||||
- name: sam
|
|
||||||
value: 4
|
|
||||||
```
|
|
||||||
then
|
|
||||||
```
|
|
||||||
yaml r sample.yaml b.e[*].name
|
|
||||||
```
|
|
||||||
will output:
|
|
||||||
```
|
|
||||||
- fred
|
|
||||||
- sam
|
|
||||||
```
|
|
||||||
|
|
||||||
## Update examples
|
|
||||||
|
|
||||||
### Update to stdout
|
|
||||||
Given a sample.yaml file of:
|
|
||||||
```yaml
|
|
||||||
b:
|
|
||||||
c: 2
|
|
||||||
```
|
|
||||||
then
|
|
||||||
```bash
|
|
||||||
yaml w sample.yaml b.c cat
|
|
||||||
```
|
|
||||||
will output:
|
|
||||||
```yaml
|
|
||||||
b:
|
|
||||||
c: cat
|
|
||||||
```
|
|
||||||
|
|
||||||
### Updating yaml in-place
|
|
||||||
Given a sample.yaml file of:
|
|
||||||
```yaml
|
|
||||||
b:
|
|
||||||
c: 2
|
|
||||||
```
|
|
||||||
then
|
|
||||||
```bash
|
|
||||||
yaml w -i sample.yaml b.c cat
|
|
||||||
```
|
|
||||||
will update the sample.yaml file so that the value of 'c' is cat.
|
|
||||||
|
|
||||||
|
|
||||||
### Updating multiple values with a script
|
|
||||||
Given a sample.yaml file of:
|
|
||||||
```yaml
|
|
||||||
b:
|
|
||||||
c: 2
|
|
||||||
e:
|
|
||||||
- name: Billy Bob
|
|
||||||
```
|
|
||||||
and a script update_instructions.yaml of:
|
|
||||||
```yaml
|
|
||||||
b.c: 3
|
|
||||||
b.e[0].name: Howdy Partner
|
|
||||||
```
|
|
||||||
then
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
yaml -w -s update_instructions.yaml sample.yaml
|
docker run -v ${PWD}:/workdir mikefarah/yq yq [flags] <command> FILE...
|
||||||
```
|
|
||||||
will output:
|
|
||||||
```yaml
|
|
||||||
b:
|
|
||||||
c: 3
|
|
||||||
e:
|
|
||||||
- name: Howdy Partner
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Run commands interactively:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker run -it -v ${PWD}:/workdir mikefarah/yq sh
|
||||||
|
```
|
||||||
|
|
||||||
|
## Features
|
||||||
|
- 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.
|
||||||
|
- Supports multiple documents in a single yaml file
|
||||||
|
|
||||||
|
## [Usage](http://mikefarah.github.io/yq/)
|
||||||
|
|
||||||
|
Check out the [documentation](http://mikefarah.github.io/yq/) for more detailed and advanced usage.
|
||||||
|
|
||||||
|
```
|
||||||
|
Usage:
|
||||||
|
yq [flags]
|
||||||
|
yq [command]
|
||||||
|
|
||||||
|
Available Commands:
|
||||||
|
delete yq d [--inplace/-i] [--doc/-d index] sample.yaml a.b.c
|
||||||
|
help Help about any command
|
||||||
|
merge yq m [--inplace/-i] [--doc/-d index] [--overwrite/-x] sample.yaml sample2.yaml
|
||||||
|
new yq n [--script/-s script_file] a.b.c newValue
|
||||||
|
read yq r [--doc/-d index] sample.yaml a.b.c
|
||||||
|
write yq w [--inplace/-i] [--script/-s script_file] [--doc/-d index] sample.yaml a.b.c newValue
|
||||||
|
|
||||||
|
Flags:
|
||||||
|
-h, --help help for yq
|
||||||
|
-t, --trim trim yaml output (default true)
|
||||||
|
-v, --verbose verbose mode
|
||||||
|
-V, --version Print version information and quit
|
||||||
|
|
||||||
|
Use "yq [command] --help" for more information about a command.
|
||||||
|
```
|
||||||
|
|
||||||
|
## Contribute
|
||||||
|
1. `make [local] vendor`
|
||||||
|
2. add unit tests
|
||||||
|
3. apply changes (use govendor with a preference to [gopkg](https://gopkg.in/) for package dependencies)
|
||||||
|
4. `make [local] build`
|
||||||
|
5. If required, update the user documentation
|
||||||
|
- Update README.md and/or documentation under the mkdocs folder
|
||||||
|
- `make [local] build-docs`
|
||||||
|
- browse to docs/index.html and check your changes
|
||||||
|
6. profit
|
||||||
|
|||||||
864
commands_test.go
Normal file
864
commands_test.go
Normal file
@@ -0,0 +1,864 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"gopkg.in/spf13/cobra.v0"
|
||||||
|
)
|
||||||
|
|
||||||
|
func getRootCommand() *cobra.Command {
|
||||||
|
return newCommandCLI()
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestRootCmd(t *testing.T) {
|
||||||
|
cmd := getRootCommand()
|
||||||
|
result := runCmd(cmd, "")
|
||||||
|
if result.Error != nil {
|
||||||
|
t.Error(result.Error)
|
||||||
|
}
|
||||||
|
|
||||||
|
if !strings.Contains(result.Output, "Usage:") {
|
||||||
|
t.Error("Expected usage message to be printed out, but the usage message was not found.")
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestRootCmd_VerboseLong(t *testing.T) {
|
||||||
|
cmd := getRootCommand()
|
||||||
|
result := runCmd(cmd, "--verbose")
|
||||||
|
if result.Error != nil {
|
||||||
|
t.Error(result.Error)
|
||||||
|
}
|
||||||
|
|
||||||
|
if !verbose {
|
||||||
|
t.Error("Expected verbose to be true")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestRootCmd_VerboseShort(t *testing.T) {
|
||||||
|
cmd := getRootCommand()
|
||||||
|
result := runCmd(cmd, "-v")
|
||||||
|
if result.Error != nil {
|
||||||
|
t.Error(result.Error)
|
||||||
|
}
|
||||||
|
|
||||||
|
if !verbose {
|
||||||
|
t.Error("Expected verbose to be true")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestRootCmd_TrimLong(t *testing.T) {
|
||||||
|
cmd := getRootCommand()
|
||||||
|
result := runCmd(cmd, "--trim")
|
||||||
|
if result.Error != nil {
|
||||||
|
t.Error(result.Error)
|
||||||
|
}
|
||||||
|
|
||||||
|
if !trimOutput {
|
||||||
|
t.Error("Expected trimOutput to be true")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestRootCmd_TrimShort(t *testing.T) {
|
||||||
|
cmd := getRootCommand()
|
||||||
|
result := runCmd(cmd, "-t")
|
||||||
|
if result.Error != nil {
|
||||||
|
t.Error(result.Error)
|
||||||
|
}
|
||||||
|
|
||||||
|
if !trimOutput {
|
||||||
|
t.Error("Expected trimOutput to be true")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestRootCmd_VersionShort(t *testing.T) {
|
||||||
|
cmd := getRootCommand()
|
||||||
|
result := runCmd(cmd, "-V")
|
||||||
|
if result.Error != nil {
|
||||||
|
t.Error(result.Error)
|
||||||
|
}
|
||||||
|
if !strings.Contains(result.Output, "yq version") {
|
||||||
|
t.Error("expected version message to be printed out, but the message was not found.")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestRootCmd_VersionLong(t *testing.T) {
|
||||||
|
cmd := getRootCommand()
|
||||||
|
result := runCmd(cmd, "--version")
|
||||||
|
if result.Error != nil {
|
||||||
|
t.Error(result.Error)
|
||||||
|
}
|
||||||
|
if !strings.Contains(result.Output, "yq version") {
|
||||||
|
t.Error("expected version message to be printed out, but the message was not found.")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestReadCmd(t *testing.T) {
|
||||||
|
cmd := getRootCommand()
|
||||||
|
result := runCmd(cmd, "read examples/sample.yaml b.c")
|
||||||
|
if result.Error != nil {
|
||||||
|
t.Error(result.Error)
|
||||||
|
}
|
||||||
|
assertResult(t, "2\n", result.Output)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestReadInvalidDocumentIndexCmd(t *testing.T) {
|
||||||
|
cmd := getRootCommand()
|
||||||
|
result := runCmd(cmd, "read -df examples/sample.yaml b.c")
|
||||||
|
if result.Error == nil {
|
||||||
|
t.Error("Expected command to fail due to invalid path")
|
||||||
|
}
|
||||||
|
expectedOutput := `Document index f is not a integer or *: strconv.ParseInt: parsing "f": invalid syntax`
|
||||||
|
assertResult(t, expectedOutput, result.Error.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestReadBadDocumentIndexCmd(t *testing.T) {
|
||||||
|
cmd := getRootCommand()
|
||||||
|
result := runCmd(cmd, "read -d1 examples/sample.yaml b.c")
|
||||||
|
if result.Error == nil {
|
||||||
|
t.Error("Expected command to fail due to invalid path")
|
||||||
|
}
|
||||||
|
expectedOutput := `Asked to process document index 1 but there are only 1 document(s)`
|
||||||
|
assertResult(t, expectedOutput, result.Error.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestReadOrderCmd(t *testing.T) {
|
||||||
|
cmd := getRootCommand()
|
||||||
|
result := runCmd(cmd, "read examples/order.yaml")
|
||||||
|
if result.Error != nil {
|
||||||
|
t.Error(result.Error)
|
||||||
|
}
|
||||||
|
assertResult(t,
|
||||||
|
`version: 3
|
||||||
|
application: MyApp
|
||||||
|
`,
|
||||||
|
result.Output)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestReadMultiCmd(t *testing.T) {
|
||||||
|
cmd := getRootCommand()
|
||||||
|
result := runCmd(cmd, "read -d 1 examples/multiple_docs.yaml another.document")
|
||||||
|
if result.Error != nil {
|
||||||
|
t.Error(result.Error)
|
||||||
|
}
|
||||||
|
assertResult(t, "here\n", result.Output)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestReadMultiAllCmd(t *testing.T) {
|
||||||
|
cmd := getRootCommand()
|
||||||
|
result := runCmd(cmd, "read -d* examples/multiple_docs.yaml commonKey")
|
||||||
|
if result.Error != nil {
|
||||||
|
t.Error(result.Error)
|
||||||
|
}
|
||||||
|
assertResult(t,
|
||||||
|
`- first document
|
||||||
|
- second document
|
||||||
|
- third document
|
||||||
|
`, result.Output)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestReadCmd_ArrayYaml(t *testing.T) {
|
||||||
|
cmd := getRootCommand()
|
||||||
|
result := runCmd(cmd, "read examples/array.yaml [0].gather_facts")
|
||||||
|
if result.Error != nil {
|
||||||
|
t.Error(result.Error)
|
||||||
|
}
|
||||||
|
assertResult(t, "false\n", result.Output)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestReadCmd_ArrayYaml_NoPath(t *testing.T) {
|
||||||
|
cmd := getRootCommand()
|
||||||
|
result := runCmd(cmd, "read examples/array.yaml")
|
||||||
|
if result.Error != nil {
|
||||||
|
t.Error(result.Error)
|
||||||
|
}
|
||||||
|
expectedOutput := `- become: true
|
||||||
|
gather_facts: false
|
||||||
|
hosts: lalaland
|
||||||
|
name: Apply smth
|
||||||
|
roles:
|
||||||
|
- lala
|
||||||
|
- land
|
||||||
|
serial: 1
|
||||||
|
`
|
||||||
|
assertResult(t, expectedOutput, result.Output)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestReadCmd_ArrayYaml_OneElement(t *testing.T) {
|
||||||
|
cmd := getRootCommand()
|
||||||
|
result := runCmd(cmd, "read examples/array.yaml [0]")
|
||||||
|
if result.Error != nil {
|
||||||
|
t.Error(result.Error)
|
||||||
|
}
|
||||||
|
expectedOutput := `become: true
|
||||||
|
gather_facts: false
|
||||||
|
hosts: lalaland
|
||||||
|
name: Apply smth
|
||||||
|
roles:
|
||||||
|
- lala
|
||||||
|
- land
|
||||||
|
serial: 1
|
||||||
|
`
|
||||||
|
assertResult(t, expectedOutput, result.Output)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestReadCmd_ArrayYaml_Splat(t *testing.T) {
|
||||||
|
cmd := getRootCommand()
|
||||||
|
result := runCmd(cmd, "read examples/array.yaml [*]")
|
||||||
|
if result.Error != nil {
|
||||||
|
t.Error(result.Error)
|
||||||
|
}
|
||||||
|
expectedOutput := `- become: true
|
||||||
|
gather_facts: false
|
||||||
|
hosts: lalaland
|
||||||
|
name: Apply smth
|
||||||
|
roles:
|
||||||
|
- lala
|
||||||
|
- land
|
||||||
|
serial: 1
|
||||||
|
`
|
||||||
|
assertResult(t, expectedOutput, result.Output)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestReadCmd_ArrayYaml_SplatKey(t *testing.T) {
|
||||||
|
cmd := getRootCommand()
|
||||||
|
result := runCmd(cmd, "read examples/array.yaml [*].gather_facts")
|
||||||
|
if result.Error != nil {
|
||||||
|
t.Error(result.Error)
|
||||||
|
}
|
||||||
|
expectedOutput := "- false\n"
|
||||||
|
assertResult(t, expectedOutput, result.Output)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestReadCmd_ArrayYaml_ErrorBadPath(t *testing.T) {
|
||||||
|
cmd := getRootCommand()
|
||||||
|
result := runCmd(cmd, "read examples/array.yaml [x].gather_facts")
|
||||||
|
if result.Error == nil {
|
||||||
|
t.Error("Expected command to fail due to invalid path")
|
||||||
|
}
|
||||||
|
expectedOutput := `Error reading path in document index 0: Error accessing array: strconv.ParseInt: parsing "x": invalid syntax`
|
||||||
|
assertResult(t, expectedOutput, result.Error.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestReadCmd_ArrayYaml_Splat_ErrorBadPath(t *testing.T) {
|
||||||
|
cmd := getRootCommand()
|
||||||
|
result := runCmd(cmd, "read examples/array.yaml [*].roles[x]")
|
||||||
|
if result.Error == nil {
|
||||||
|
t.Error("Expected command to fail due to invalid path")
|
||||||
|
}
|
||||||
|
expectedOutput := `Error reading path in document index 0: Error accessing array: strconv.ParseInt: parsing "x": invalid syntax`
|
||||||
|
assertResult(t, expectedOutput, result.Error.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestReadCmd_Error(t *testing.T) {
|
||||||
|
cmd := getRootCommand()
|
||||||
|
result := runCmd(cmd, "read")
|
||||||
|
if result.Error == nil {
|
||||||
|
t.Error("Expected command to fail due to missing arg")
|
||||||
|
}
|
||||||
|
expectedOutput := `Must provide filename`
|
||||||
|
assertResult(t, expectedOutput, result.Error.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestReadCmd_ErrorEmptyFilename(t *testing.T) {
|
||||||
|
cmd := getRootCommand()
|
||||||
|
result := runCmd(cmd, "read ")
|
||||||
|
if result.Error == nil {
|
||||||
|
t.Error("Expected command to fail due to missing arg")
|
||||||
|
}
|
||||||
|
expectedOutput := `Must provide filename`
|
||||||
|
assertResult(t, expectedOutput, result.Error.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestReadCmd_ErrorUnreadableFile(t *testing.T) {
|
||||||
|
cmd := getRootCommand()
|
||||||
|
result := runCmd(cmd, "read fake-unknown")
|
||||||
|
if result.Error == nil {
|
||||||
|
t.Error("Expected command to fail due to unknown file")
|
||||||
|
}
|
||||||
|
expectedOutput := `open fake-unknown: no such file or directory`
|
||||||
|
assertResult(t, expectedOutput, result.Error.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestReadCmd_ErrorBadPath(t *testing.T) {
|
||||||
|
content := `b:
|
||||||
|
d:
|
||||||
|
e:
|
||||||
|
- 3
|
||||||
|
- 4
|
||||||
|
f:
|
||||||
|
- 1
|
||||||
|
- 2
|
||||||
|
`
|
||||||
|
filename := writeTempYamlFile(content)
|
||||||
|
defer removeTempYamlFile(filename)
|
||||||
|
|
||||||
|
cmd := getRootCommand()
|
||||||
|
result := runCmd(cmd, fmt.Sprintf("read %s b.d.*.[x]", filename))
|
||||||
|
if result.Error == nil {
|
||||||
|
t.Fatal("Expected command to fail due to invalid path")
|
||||||
|
}
|
||||||
|
expectedOutput := `Error reading path in document index 0: Error accessing array: strconv.ParseInt: parsing "x": invalid syntax`
|
||||||
|
assertResult(t, expectedOutput, result.Error.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestReadCmd_Verbose(t *testing.T) {
|
||||||
|
cmd := getRootCommand()
|
||||||
|
result := runCmd(cmd, "-v read examples/sample.yaml b.c")
|
||||||
|
if result.Error != nil {
|
||||||
|
t.Error(result.Error)
|
||||||
|
}
|
||||||
|
assertResult(t, "2\n", result.Output)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestReadCmd_NoTrim(t *testing.T) {
|
||||||
|
cmd := getRootCommand()
|
||||||
|
result := runCmd(cmd, "--trim=false read examples/sample.yaml b.c")
|
||||||
|
if result.Error != nil {
|
||||||
|
t.Error(result.Error)
|
||||||
|
}
|
||||||
|
assertResult(t, "2\n\n", result.Output)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestReadCmd_ToJson(t *testing.T) {
|
||||||
|
cmd := getRootCommand()
|
||||||
|
result := runCmd(cmd, "read -j examples/sample.yaml b.c")
|
||||||
|
if result.Error != nil {
|
||||||
|
t.Error(result.Error)
|
||||||
|
}
|
||||||
|
assertResult(t, "2\n", result.Output)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestReadCmd_ToJsonLong(t *testing.T) {
|
||||||
|
cmd := getRootCommand()
|
||||||
|
result := runCmd(cmd, "read --tojson examples/sample.yaml b.c")
|
||||||
|
if result.Error != nil {
|
||||||
|
t.Error(result.Error)
|
||||||
|
}
|
||||||
|
assertResult(t, "2\n", result.Output)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestNewCmd(t *testing.T) {
|
||||||
|
cmd := getRootCommand()
|
||||||
|
result := runCmd(cmd, "new b.c 3")
|
||||||
|
if result.Error != nil {
|
||||||
|
t.Error(result.Error)
|
||||||
|
}
|
||||||
|
expectedOutput := `b:
|
||||||
|
c: 3
|
||||||
|
`
|
||||||
|
assertResult(t, expectedOutput, result.Output)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestNewCmd_Error(t *testing.T) {
|
||||||
|
cmd := getRootCommand()
|
||||||
|
result := runCmd(cmd, "new b.c")
|
||||||
|
if result.Error == nil {
|
||||||
|
t.Error("Expected command to fail due to missing arg")
|
||||||
|
}
|
||||||
|
expectedOutput := `Must provide <path_to_update> <value>`
|
||||||
|
assertResult(t, expectedOutput, result.Error.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestNewCmd_Verbose(t *testing.T) {
|
||||||
|
cmd := getRootCommand()
|
||||||
|
result := runCmd(cmd, "-v new b.c 3")
|
||||||
|
if result.Error != nil {
|
||||||
|
t.Error(result.Error)
|
||||||
|
}
|
||||||
|
expectedOutput := `b:
|
||||||
|
c: 3
|
||||||
|
`
|
||||||
|
assertResult(t, expectedOutput, result.Output)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestWriteCmd(t *testing.T) {
|
||||||
|
content := `b:
|
||||||
|
c: 3
|
||||||
|
`
|
||||||
|
filename := writeTempYamlFile(content)
|
||||||
|
defer removeTempYamlFile(filename)
|
||||||
|
|
||||||
|
cmd := getRootCommand()
|
||||||
|
result := runCmd(cmd, fmt.Sprintf("write %s b.c 7", filename))
|
||||||
|
if result.Error != nil {
|
||||||
|
t.Error(result.Error)
|
||||||
|
}
|
||||||
|
expectedOutput := `b:
|
||||||
|
c: 7
|
||||||
|
`
|
||||||
|
assertResult(t, expectedOutput, result.Output)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestWriteMultiCmd(t *testing.T) {
|
||||||
|
content := `b:
|
||||||
|
c: 3
|
||||||
|
---
|
||||||
|
apples: great
|
||||||
|
`
|
||||||
|
filename := writeTempYamlFile(content)
|
||||||
|
defer removeTempYamlFile(filename)
|
||||||
|
|
||||||
|
cmd := getRootCommand()
|
||||||
|
result := runCmd(cmd, fmt.Sprintf("write %s -d 1 apples ok", filename))
|
||||||
|
if result.Error != nil {
|
||||||
|
t.Error(result.Error)
|
||||||
|
}
|
||||||
|
expectedOutput := `b:
|
||||||
|
c: 3
|
||||||
|
---
|
||||||
|
apples: ok
|
||||||
|
`
|
||||||
|
assertResult(t, expectedOutput, result.Output)
|
||||||
|
}
|
||||||
|
func TestWriteInvalidDocumentIndexCmd(t *testing.T) {
|
||||||
|
content := `b:
|
||||||
|
c: 3
|
||||||
|
`
|
||||||
|
filename := writeTempYamlFile(content)
|
||||||
|
defer removeTempYamlFile(filename)
|
||||||
|
|
||||||
|
cmd := getRootCommand()
|
||||||
|
result := runCmd(cmd, fmt.Sprintf("write %s -df apples ok", filename))
|
||||||
|
if result.Error == nil {
|
||||||
|
t.Error("Expected command to fail due to invalid path")
|
||||||
|
}
|
||||||
|
expectedOutput := `Document index f is not a integer or *: strconv.ParseInt: parsing "f": invalid syntax`
|
||||||
|
assertResult(t, expectedOutput, result.Error.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestWriteBadDocumentIndexCmd(t *testing.T) {
|
||||||
|
content := `b:
|
||||||
|
c: 3
|
||||||
|
`
|
||||||
|
filename := writeTempYamlFile(content)
|
||||||
|
defer removeTempYamlFile(filename)
|
||||||
|
|
||||||
|
cmd := getRootCommand()
|
||||||
|
result := runCmd(cmd, fmt.Sprintf("write %s -d 1 apples ok", filename))
|
||||||
|
if result.Error == nil {
|
||||||
|
t.Error("Expected command to fail due to invalid path")
|
||||||
|
}
|
||||||
|
expectedOutput := `Asked to process document index 1 but there are only 1 document(s)`
|
||||||
|
assertResult(t, expectedOutput, result.Error.Error())
|
||||||
|
}
|
||||||
|
func TestWriteMultiAllCmd(t *testing.T) {
|
||||||
|
content := `b:
|
||||||
|
c: 3
|
||||||
|
---
|
||||||
|
apples: great
|
||||||
|
`
|
||||||
|
filename := writeTempYamlFile(content)
|
||||||
|
defer removeTempYamlFile(filename)
|
||||||
|
|
||||||
|
cmd := getRootCommand()
|
||||||
|
result := runCmd(cmd, fmt.Sprintf("write %s -d * apples ok", filename))
|
||||||
|
if result.Error != nil {
|
||||||
|
t.Error(result.Error)
|
||||||
|
}
|
||||||
|
expectedOutput := `b:
|
||||||
|
c: 3
|
||||||
|
apples: ok
|
||||||
|
---
|
||||||
|
apples: ok`
|
||||||
|
assertResult(t, expectedOutput, strings.Trim(result.Output, "\n "))
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestWriteCmd_EmptyArray(t *testing.T) {
|
||||||
|
content := `b: 3`
|
||||||
|
filename := writeTempYamlFile(content)
|
||||||
|
defer removeTempYamlFile(filename)
|
||||||
|
|
||||||
|
cmd := getRootCommand()
|
||||||
|
result := runCmd(cmd, fmt.Sprintf("write %s a []", filename))
|
||||||
|
if result.Error != nil {
|
||||||
|
t.Error(result.Error)
|
||||||
|
}
|
||||||
|
expectedOutput := `b: 3
|
||||||
|
a: []
|
||||||
|
`
|
||||||
|
assertResult(t, expectedOutput, result.Output)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestWriteCmd_Error(t *testing.T) {
|
||||||
|
cmd := getRootCommand()
|
||||||
|
result := runCmd(cmd, "write")
|
||||||
|
if result.Error == nil {
|
||||||
|
t.Error("Expected command to fail due to missing arg")
|
||||||
|
}
|
||||||
|
expectedOutput := `Must provide <filename> <path_to_update> <value>`
|
||||||
|
assertResult(t, expectedOutput, result.Error.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestWriteCmd_ErrorUnreadableFile(t *testing.T) {
|
||||||
|
cmd := getRootCommand()
|
||||||
|
result := runCmd(cmd, "write fake-unknown a.b 3")
|
||||||
|
if result.Error == nil {
|
||||||
|
t.Error("Expected command to fail due to unknown file")
|
||||||
|
}
|
||||||
|
expectedOutput := `open fake-unknown: no such file or directory`
|
||||||
|
assertResult(t, expectedOutput, result.Error.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestWriteCmd_Verbose(t *testing.T) {
|
||||||
|
content := `b:
|
||||||
|
c: 3
|
||||||
|
`
|
||||||
|
filename := writeTempYamlFile(content)
|
||||||
|
defer removeTempYamlFile(filename)
|
||||||
|
|
||||||
|
cmd := getRootCommand()
|
||||||
|
result := runCmd(cmd, fmt.Sprintf("-v write %s b.c 7", filename))
|
||||||
|
if result.Error != nil {
|
||||||
|
t.Error(result.Error)
|
||||||
|
}
|
||||||
|
expectedOutput := `b:
|
||||||
|
c: 7
|
||||||
|
`
|
||||||
|
assertResult(t, expectedOutput, result.Output)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestWriteCmd_Inplace(t *testing.T) {
|
||||||
|
content := `b:
|
||||||
|
c: 3
|
||||||
|
`
|
||||||
|
filename := writeTempYamlFile(content)
|
||||||
|
defer removeTempYamlFile(filename)
|
||||||
|
|
||||||
|
cmd := getRootCommand()
|
||||||
|
result := runCmd(cmd, fmt.Sprintf("write -i %s b.c 7", filename))
|
||||||
|
if result.Error != nil {
|
||||||
|
t.Error(result.Error)
|
||||||
|
}
|
||||||
|
gotOutput := readTempYamlFile(filename)
|
||||||
|
expectedOutput := `b:
|
||||||
|
c: 7`
|
||||||
|
assertResult(t, expectedOutput, strings.Trim(gotOutput, "\n "))
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestWriteCmd_Append(t *testing.T) {
|
||||||
|
content := `b:
|
||||||
|
- foo
|
||||||
|
`
|
||||||
|
filename := writeTempYamlFile(content)
|
||||||
|
defer removeTempYamlFile(filename)
|
||||||
|
|
||||||
|
cmd := getRootCommand()
|
||||||
|
result := runCmd(cmd, fmt.Sprintf("write %s b[+] 7", filename))
|
||||||
|
if result.Error != nil {
|
||||||
|
t.Error(result.Error)
|
||||||
|
}
|
||||||
|
expectedOutput := `b:
|
||||||
|
- foo
|
||||||
|
- 7
|
||||||
|
`
|
||||||
|
assertResult(t, expectedOutput, result.Output)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestWriteCmd_AppendEmptyArray(t *testing.T) {
|
||||||
|
content := `a: 2
|
||||||
|
`
|
||||||
|
filename := writeTempYamlFile(content)
|
||||||
|
defer removeTempYamlFile(filename)
|
||||||
|
|
||||||
|
cmd := getRootCommand()
|
||||||
|
result := runCmd(cmd, fmt.Sprintf("write %s b[+] v", filename))
|
||||||
|
if result.Error != nil {
|
||||||
|
t.Error(result.Error)
|
||||||
|
}
|
||||||
|
expectedOutput := `a: 2
|
||||||
|
b:
|
||||||
|
- v
|
||||||
|
`
|
||||||
|
assertResult(t, expectedOutput, result.Output)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestDeleteYaml(t *testing.T) {
|
||||||
|
content := `a: 2
|
||||||
|
b:
|
||||||
|
c: things
|
||||||
|
d: something else
|
||||||
|
`
|
||||||
|
filename := writeTempYamlFile(content)
|
||||||
|
defer removeTempYamlFile(filename)
|
||||||
|
|
||||||
|
cmd := getRootCommand()
|
||||||
|
result := runCmd(cmd, fmt.Sprintf("delete %s b.c", filename))
|
||||||
|
if result.Error != nil {
|
||||||
|
t.Error(result.Error)
|
||||||
|
}
|
||||||
|
|
||||||
|
expectedOutput := `a: 2
|
||||||
|
b:
|
||||||
|
d: something else
|
||||||
|
`
|
||||||
|
assertResult(t, expectedOutput, result.Output)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestDeleteYamlArray(t *testing.T) {
|
||||||
|
content := `- 1
|
||||||
|
- 2
|
||||||
|
- 3
|
||||||
|
`
|
||||||
|
filename := writeTempYamlFile(content)
|
||||||
|
defer removeTempYamlFile(filename)
|
||||||
|
|
||||||
|
cmd := getRootCommand()
|
||||||
|
result := runCmd(cmd, fmt.Sprintf("delete %s [1]", filename))
|
||||||
|
if result.Error != nil {
|
||||||
|
t.Error(result.Error)
|
||||||
|
}
|
||||||
|
|
||||||
|
expectedOutput := `- 1
|
||||||
|
- 3
|
||||||
|
`
|
||||||
|
assertResult(t, expectedOutput, result.Output)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestDeleteYamlMulti(t *testing.T) {
|
||||||
|
content := `apples: great
|
||||||
|
---
|
||||||
|
- 1
|
||||||
|
- 2
|
||||||
|
- 3
|
||||||
|
`
|
||||||
|
filename := writeTempYamlFile(content)
|
||||||
|
defer removeTempYamlFile(filename)
|
||||||
|
|
||||||
|
cmd := getRootCommand()
|
||||||
|
result := runCmd(cmd, fmt.Sprintf("delete -d 1 %s [1]", filename))
|
||||||
|
if result.Error != nil {
|
||||||
|
t.Error(result.Error)
|
||||||
|
}
|
||||||
|
|
||||||
|
expectedOutput := `apples: great
|
||||||
|
---
|
||||||
|
- 1
|
||||||
|
- 3
|
||||||
|
`
|
||||||
|
assertResult(t, expectedOutput, result.Output)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestDeleteYamlMultiAllCmd(t *testing.T) {
|
||||||
|
content := `b:
|
||||||
|
c: 3
|
||||||
|
apples: great
|
||||||
|
---
|
||||||
|
apples: great
|
||||||
|
something: else
|
||||||
|
`
|
||||||
|
filename := writeTempYamlFile(content)
|
||||||
|
defer removeTempYamlFile(filename)
|
||||||
|
|
||||||
|
cmd := getRootCommand()
|
||||||
|
result := runCmd(cmd, fmt.Sprintf("delete %s -d * apples", filename))
|
||||||
|
if result.Error != nil {
|
||||||
|
t.Error(result.Error)
|
||||||
|
}
|
||||||
|
expectedOutput := `b:
|
||||||
|
c: 3
|
||||||
|
---
|
||||||
|
something: else`
|
||||||
|
assertResult(t, expectedOutput, strings.Trim(result.Output, "\n "))
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestMergeCmd(t *testing.T) {
|
||||||
|
cmd := getRootCommand()
|
||||||
|
result := runCmd(cmd, "merge examples/data1.yaml examples/data2.yaml")
|
||||||
|
if result.Error != nil {
|
||||||
|
t.Error(result.Error)
|
||||||
|
}
|
||||||
|
expectedOutput := `a: simple
|
||||||
|
b:
|
||||||
|
- 1
|
||||||
|
- 2
|
||||||
|
c:
|
||||||
|
test: 1
|
||||||
|
`
|
||||||
|
assertResult(t, expectedOutput, result.Output)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestMergeOverwriteCmd(t *testing.T) {
|
||||||
|
cmd := getRootCommand()
|
||||||
|
result := runCmd(cmd, "merge --overwrite examples/data1.yaml examples/data2.yaml")
|
||||||
|
if result.Error != nil {
|
||||||
|
t.Error(result.Error)
|
||||||
|
}
|
||||||
|
expectedOutput := `a: other
|
||||||
|
b:
|
||||||
|
- 3
|
||||||
|
- 4
|
||||||
|
c:
|
||||||
|
test: 1
|
||||||
|
`
|
||||||
|
assertResult(t, expectedOutput, result.Output)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestMergeAppendCmd(t *testing.T) {
|
||||||
|
cmd := getRootCommand()
|
||||||
|
result := runCmd(cmd, "merge --append examples/data1.yaml examples/data2.yaml")
|
||||||
|
if result.Error != nil {
|
||||||
|
t.Error(result.Error)
|
||||||
|
}
|
||||||
|
expectedOutput := `a: simple
|
||||||
|
b:
|
||||||
|
- 1
|
||||||
|
- 2
|
||||||
|
- 3
|
||||||
|
- 4
|
||||||
|
c:
|
||||||
|
test: 1
|
||||||
|
`
|
||||||
|
assertResult(t, expectedOutput, result.Output)
|
||||||
|
}
|
||||||
|
func TestMergeArraysCmd(t *testing.T) {
|
||||||
|
cmd := getRootCommand()
|
||||||
|
result := runCmd(cmd, "merge --append examples/sample_array.yaml examples/sample_array_2.yaml")
|
||||||
|
if result.Error != nil {
|
||||||
|
t.Error(result.Error)
|
||||||
|
}
|
||||||
|
expectedOutput := `- 1
|
||||||
|
- 2
|
||||||
|
- 3
|
||||||
|
- 4
|
||||||
|
- 5
|
||||||
|
`
|
||||||
|
assertResult(t, expectedOutput, result.Output)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestMergeCmd_Multi(t *testing.T) {
|
||||||
|
cmd := getRootCommand()
|
||||||
|
result := runCmd(cmd, "merge -d1 examples/multiple_docs_small.yaml examples/data2.yaml")
|
||||||
|
if result.Error != nil {
|
||||||
|
t.Error(result.Error)
|
||||||
|
}
|
||||||
|
expectedOutput := `a: Easy! as one two three
|
||||||
|
---
|
||||||
|
a: other
|
||||||
|
another:
|
||||||
|
document: here
|
||||||
|
b:
|
||||||
|
- 3
|
||||||
|
- 4
|
||||||
|
c:
|
||||||
|
test: 1
|
||||||
|
---
|
||||||
|
- 1
|
||||||
|
- 2`
|
||||||
|
assertResult(t, expectedOutput, strings.Trim(result.Output, "\n "))
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestMergeYamlMultiAllCmd(t *testing.T) {
|
||||||
|
content := `b:
|
||||||
|
c: 3
|
||||||
|
apples: green
|
||||||
|
---
|
||||||
|
something: else`
|
||||||
|
filename := writeTempYamlFile(content)
|
||||||
|
defer removeTempYamlFile(filename)
|
||||||
|
|
||||||
|
mergeContent := `apples: red
|
||||||
|
something: good`
|
||||||
|
mergeFilename := writeTempYamlFile(mergeContent)
|
||||||
|
defer removeTempYamlFile(mergeFilename)
|
||||||
|
|
||||||
|
cmd := getRootCommand()
|
||||||
|
result := runCmd(cmd, fmt.Sprintf("merge -d* %s %s", filename, mergeFilename))
|
||||||
|
if result.Error != nil {
|
||||||
|
t.Error(result.Error)
|
||||||
|
}
|
||||||
|
expectedOutput := `apples: green
|
||||||
|
b:
|
||||||
|
c: 3
|
||||||
|
something: good
|
||||||
|
---
|
||||||
|
apples: red
|
||||||
|
something: else`
|
||||||
|
assertResult(t, expectedOutput, strings.Trim(result.Output, "\n "))
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestMergeYamlMultiAllOverwriteCmd(t *testing.T) {
|
||||||
|
content := `b:
|
||||||
|
c: 3
|
||||||
|
apples: green
|
||||||
|
---
|
||||||
|
something: else`
|
||||||
|
filename := writeTempYamlFile(content)
|
||||||
|
defer removeTempYamlFile(filename)
|
||||||
|
|
||||||
|
mergeContent := `apples: red
|
||||||
|
something: good`
|
||||||
|
mergeFilename := writeTempYamlFile(mergeContent)
|
||||||
|
defer removeTempYamlFile(mergeFilename)
|
||||||
|
|
||||||
|
cmd := getRootCommand()
|
||||||
|
result := runCmd(cmd, fmt.Sprintf("merge --overwrite -d* %s %s", filename, mergeFilename))
|
||||||
|
if result.Error != nil {
|
||||||
|
t.Error(result.Error)
|
||||||
|
}
|
||||||
|
expectedOutput := `apples: red
|
||||||
|
b:
|
||||||
|
c: 3
|
||||||
|
something: good
|
||||||
|
---
|
||||||
|
apples: red
|
||||||
|
something: good`
|
||||||
|
assertResult(t, expectedOutput, strings.Trim(result.Output, "\n "))
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestMergeCmd_Error(t *testing.T) {
|
||||||
|
cmd := getRootCommand()
|
||||||
|
result := runCmd(cmd, "merge examples/data1.yaml")
|
||||||
|
if result.Error == nil {
|
||||||
|
t.Error("Expected command to fail due to missing arg")
|
||||||
|
}
|
||||||
|
expectedOutput := `Must provide at least 2 yaml files`
|
||||||
|
assertResult(t, expectedOutput, result.Error.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestMergeCmd_ErrorUnreadableFile(t *testing.T) {
|
||||||
|
cmd := getRootCommand()
|
||||||
|
result := runCmd(cmd, "merge examples/data1.yaml fake-unknown")
|
||||||
|
if result.Error == nil {
|
||||||
|
t.Error("Expected command to fail due to unknown file")
|
||||||
|
}
|
||||||
|
expectedOutput := `Error updating document at index 0: open fake-unknown: no such file or directory`
|
||||||
|
assertResult(t, expectedOutput, result.Error.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestMergeCmd_Verbose(t *testing.T) {
|
||||||
|
cmd := getRootCommand()
|
||||||
|
result := runCmd(cmd, "-v merge examples/data1.yaml examples/data2.yaml")
|
||||||
|
if result.Error != nil {
|
||||||
|
t.Error(result.Error)
|
||||||
|
}
|
||||||
|
expectedOutput := `a: simple
|
||||||
|
b:
|
||||||
|
- 1
|
||||||
|
- 2
|
||||||
|
c:
|
||||||
|
test: 1
|
||||||
|
`
|
||||||
|
assertResult(t, expectedOutput, result.Output)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestMergeCmd_Inplace(t *testing.T) {
|
||||||
|
filename := writeTempYamlFile(readTempYamlFile("examples/data1.yaml"))
|
||||||
|
defer removeTempYamlFile(filename)
|
||||||
|
|
||||||
|
cmd := getRootCommand()
|
||||||
|
result := runCmd(cmd, fmt.Sprintf("merge -i %s examples/data2.yaml", filename))
|
||||||
|
if result.Error != nil {
|
||||||
|
t.Error(result.Error)
|
||||||
|
}
|
||||||
|
gotOutput := readTempYamlFile(filename)
|
||||||
|
expectedOutput := `a: simple
|
||||||
|
b:
|
||||||
|
- 1
|
||||||
|
- 2
|
||||||
|
c:
|
||||||
|
test: 1`
|
||||||
|
assertResult(t, expectedOutput, strings.Trim(gotOutput, "\n "))
|
||||||
|
}
|
||||||
@@ -1,45 +1,153 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
// "fmt"
|
"fmt"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
|
yaml "gopkg.in/mikefarah/yaml.v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
func write(context map[interface{}]interface{}, head string, tail []string, value interface{}) {
|
func entryInSlice(context yaml.MapSlice, key interface{}) *yaml.MapItem {
|
||||||
if len(tail) == 0 {
|
for idx := range context {
|
||||||
context[head] = value
|
var entry = &context[idx]
|
||||||
} else {
|
if entry.Key == key {
|
||||||
// e.g. if updating a.b.c, we need to get the 'b' map...
|
return entry
|
||||||
toUpdate := readMap(context, head, tail[0:len(tail)-1]).(map[interface{}]interface{})
|
}
|
||||||
// and then set the 'c' key.
|
|
||||||
key := (tail[len(tail)-1])
|
|
||||||
toUpdate[key] = value
|
|
||||||
}
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func readMap(context map[interface{}]interface{}, head string, tail []string) interface{} {
|
func getMapSlice(context interface{}) yaml.MapSlice {
|
||||||
|
var mapSlice yaml.MapSlice
|
||||||
|
switch context.(type) {
|
||||||
|
case yaml.MapSlice:
|
||||||
|
mapSlice = context.(yaml.MapSlice)
|
||||||
|
default:
|
||||||
|
mapSlice = make(yaml.MapSlice, 0)
|
||||||
|
}
|
||||||
|
return mapSlice
|
||||||
|
}
|
||||||
|
|
||||||
|
func getArray(context interface{}) (array []interface{}, ok bool) {
|
||||||
|
switch context.(type) {
|
||||||
|
case []interface{}:
|
||||||
|
array = context.([]interface{})
|
||||||
|
ok = true
|
||||||
|
default:
|
||||||
|
array = make([]interface{}, 0)
|
||||||
|
ok = false
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func writeMap(context interface{}, paths []string, value interface{}) yaml.MapSlice {
|
||||||
|
log.Debugf("writeMap for %v for %v with value %v\n", paths, context, value)
|
||||||
|
|
||||||
|
mapSlice := getMapSlice(context)
|
||||||
|
|
||||||
|
if len(paths) == 0 {
|
||||||
|
return mapSlice
|
||||||
|
}
|
||||||
|
|
||||||
|
child := entryInSlice(mapSlice, paths[0])
|
||||||
|
if child == nil {
|
||||||
|
newChild := yaml.MapItem{Key: paths[0]}
|
||||||
|
mapSlice = append(mapSlice, newChild)
|
||||||
|
child = entryInSlice(mapSlice, paths[0])
|
||||||
|
log.Debugf("\tAppended child at %v for mapSlice %v\n", paths[0], mapSlice)
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Debugf("\tchild.Value %v\n", child.Value)
|
||||||
|
|
||||||
|
remainingPaths := paths[1:]
|
||||||
|
child.Value = updatedChildValue(child.Value, remainingPaths, value)
|
||||||
|
log.Debugf("\tReturning mapSlice %v\n", mapSlice)
|
||||||
|
return mapSlice
|
||||||
|
}
|
||||||
|
|
||||||
|
func updatedChildValue(child interface{}, remainingPaths []string, value interface{}) interface{} {
|
||||||
|
if len(remainingPaths) == 0 {
|
||||||
|
return value
|
||||||
|
}
|
||||||
|
|
||||||
|
_, nextIndexErr := strconv.ParseInt(remainingPaths[0], 10, 64)
|
||||||
|
if nextIndexErr != nil && remainingPaths[0] != "+" {
|
||||||
|
// must be a map
|
||||||
|
return writeMap(child, remainingPaths, value)
|
||||||
|
}
|
||||||
|
|
||||||
|
// must be an array
|
||||||
|
return writeArray(child, remainingPaths, value)
|
||||||
|
}
|
||||||
|
|
||||||
|
func writeArray(context interface{}, paths []string, value interface{}) []interface{} {
|
||||||
|
log.Debugf("writeArray for %v for %v with value %v\n", paths, context, value)
|
||||||
|
array, _ := getArray(context)
|
||||||
|
|
||||||
|
if len(paths) == 0 {
|
||||||
|
return array
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Debugf("\tarray %v\n", array)
|
||||||
|
|
||||||
|
rawIndex := paths[0]
|
||||||
|
var index int64
|
||||||
|
// the append array indicator
|
||||||
|
if rawIndex == "+" {
|
||||||
|
index = int64(len(array))
|
||||||
|
} else {
|
||||||
|
index, _ = strconv.ParseInt(rawIndex, 10, 64)
|
||||||
|
}
|
||||||
|
// writeArray is only called by updatedChildValue which handles parsing the
|
||||||
|
// index, as such this renders this dead code.
|
||||||
|
// if err != nil {
|
||||||
|
// return array, fmt.Errorf("Error accessing array: %v", err)
|
||||||
|
// }
|
||||||
|
for index >= int64(len(array)) {
|
||||||
|
array = append(array, nil)
|
||||||
|
}
|
||||||
|
currentChild := array[index]
|
||||||
|
|
||||||
|
log.Debugf("\tcurrentChild %v\n", currentChild)
|
||||||
|
|
||||||
|
remainingPaths := paths[1:]
|
||||||
|
array[index] = updatedChildValue(currentChild, remainingPaths, value)
|
||||||
|
log.Debugf("\tReturning array %v\n", array)
|
||||||
|
return array
|
||||||
|
}
|
||||||
|
|
||||||
|
func readMap(context yaml.MapSlice, head string, tail []string) (interface{}, error) {
|
||||||
if head == "*" {
|
if head == "*" {
|
||||||
return readMapSplat(context, tail)
|
return readMapSplat(context, tail)
|
||||||
}
|
}
|
||||||
value := context[head]
|
var value interface{}
|
||||||
|
|
||||||
|
entry := entryInSlice(context, head)
|
||||||
|
if entry != nil {
|
||||||
|
value = entry.Value
|
||||||
|
}
|
||||||
return calculateValue(value, tail)
|
return calculateValue(value, tail)
|
||||||
}
|
}
|
||||||
|
|
||||||
func readMapSplat(context map[interface{}]interface{}, tail []string) interface{} {
|
func readMapSplat(context yaml.MapSlice, tail []string) (interface{}, error) {
|
||||||
var newArray = make([]interface{}, len(context))
|
var newArray = make([]interface{}, len(context))
|
||||||
var i = 0
|
var i = 0
|
||||||
for _, value := range context {
|
for _, entry := range context {
|
||||||
if len(tail) > 0 {
|
if len(tail) > 0 {
|
||||||
newArray[i] = recurse(value, tail[0], tail[1:len(tail)])
|
val, err := recurse(entry.Value, tail[0], tail[1:])
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
newArray[i] = val
|
||||||
} else {
|
} else {
|
||||||
newArray[i] = value
|
newArray[i] = entry.Value
|
||||||
}
|
}
|
||||||
i++
|
i++
|
||||||
}
|
}
|
||||||
return newArray
|
return newArray, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func recurse(value interface{}, head string, tail []string) interface{} {
|
func recurse(value interface{}, head string, tail []string) (interface{}, error) {
|
||||||
switch value.(type) {
|
switch value.(type) {
|
||||||
case []interface{}:
|
case []interface{}:
|
||||||
if head == "*" {
|
if head == "*" {
|
||||||
@@ -47,37 +155,130 @@ func recurse(value interface{}, head string, tail []string) interface{} {
|
|||||||
}
|
}
|
||||||
index, err := strconv.ParseInt(head, 10, 64)
|
index, err := strconv.ParseInt(head, 10, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
die("Error accessing array: %v", err)
|
return nil, fmt.Errorf("Error accessing array: %v", err)
|
||||||
}
|
}
|
||||||
return readArray(value.([]interface{}), index, tail)
|
return readArray(value.([]interface{}), index, tail)
|
||||||
case map[interface{}]interface{}:
|
case yaml.MapSlice:
|
||||||
return readMap(value.(map[interface{}]interface{}), head, tail)
|
return readMap(value.(yaml.MapSlice), head, tail)
|
||||||
default:
|
default:
|
||||||
return nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func readArray(array []interface{}, head int64, tail []string) interface{} {
|
func readArray(array []interface{}, head int64, tail []string) (interface{}, error) {
|
||||||
if head > int64(len(array)) {
|
if head >= int64(len(array)) {
|
||||||
return nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
value := array[head]
|
value := array[head]
|
||||||
|
|
||||||
return calculateValue(value, tail)
|
return calculateValue(value, tail)
|
||||||
}
|
}
|
||||||
|
|
||||||
func readArraySplat(array []interface{}, tail []string) interface{} {
|
func readArraySplat(array []interface{}, tail []string) (interface{}, error) {
|
||||||
var newArray = make([]interface{}, len(array))
|
var newArray = make([]interface{}, len(array))
|
||||||
for index, value := range array {
|
for index, value := range array {
|
||||||
newArray[index] = calculateValue(value, tail)
|
val, err := calculateValue(value, tail)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
newArray[index] = val
|
||||||
}
|
}
|
||||||
return newArray
|
return newArray, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func calculateValue(value interface{}, tail []string) interface{} {
|
func calculateValue(value interface{}, tail []string) (interface{}, error) {
|
||||||
if len(tail) > 0 {
|
if len(tail) > 0 {
|
||||||
return recurse(value, tail[0], tail[1:len(tail)])
|
return recurse(value, tail[0], tail[1:])
|
||||||
}
|
}
|
||||||
return value
|
return value, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func deleteMap(context interface{}, paths []string) yaml.MapSlice {
|
||||||
|
log.Debugf("deleteMap for %v for %v\n", paths, context)
|
||||||
|
|
||||||
|
mapSlice := getMapSlice(context)
|
||||||
|
|
||||||
|
if len(paths) == 0 {
|
||||||
|
return mapSlice
|
||||||
|
}
|
||||||
|
|
||||||
|
var found bool
|
||||||
|
var index int
|
||||||
|
var child yaml.MapItem
|
||||||
|
for index, child = range mapSlice {
|
||||||
|
if child.Key == paths[0] {
|
||||||
|
found = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if !found {
|
||||||
|
return mapSlice
|
||||||
|
}
|
||||||
|
|
||||||
|
remainingPaths := paths[1:]
|
||||||
|
|
||||||
|
var newSlice yaml.MapSlice
|
||||||
|
if len(remainingPaths) > 0 {
|
||||||
|
newChild := yaml.MapItem{Key: child.Key}
|
||||||
|
newChild.Value = deleteChildValue(child.Value, remainingPaths)
|
||||||
|
|
||||||
|
newSlice = make(yaml.MapSlice, len(mapSlice))
|
||||||
|
for i := range mapSlice {
|
||||||
|
item := mapSlice[i]
|
||||||
|
if i == index {
|
||||||
|
item = newChild
|
||||||
|
}
|
||||||
|
newSlice[i] = item
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Delete item from slice at index
|
||||||
|
newSlice = append(mapSlice[:index], mapSlice[index+1:]...)
|
||||||
|
log.Debugf("\tDeleted item index %d from mapSlice", index)
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Debugf("\t\tlen: %d\tcap: %d\tslice: %v", len(mapSlice), cap(mapSlice), mapSlice)
|
||||||
|
log.Debugf("\tReturning mapSlice %v\n", mapSlice)
|
||||||
|
return newSlice
|
||||||
|
}
|
||||||
|
|
||||||
|
func deleteArray(context interface{}, paths []string, index int64) interface{} {
|
||||||
|
log.Debugf("deleteArray for %v for %v\n", paths, context)
|
||||||
|
|
||||||
|
array, ok := getArray(context)
|
||||||
|
if !ok {
|
||||||
|
// did not get an array
|
||||||
|
return context
|
||||||
|
}
|
||||||
|
|
||||||
|
if index >= int64(len(array)) {
|
||||||
|
return array
|
||||||
|
}
|
||||||
|
|
||||||
|
remainingPaths := paths[1:]
|
||||||
|
if len(remainingPaths) > 0 {
|
||||||
|
// Recurse into the array element at index
|
||||||
|
array[index] = deleteMap(array[index], remainingPaths)
|
||||||
|
} else {
|
||||||
|
// Delete the array element at index
|
||||||
|
array = append(array[:index], array[index+1:]...)
|
||||||
|
log.Debugf("\tDeleted item index %d from array, leaving %v", index, array)
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Debugf("\tReturning array: %v\n", array)
|
||||||
|
return array
|
||||||
|
}
|
||||||
|
|
||||||
|
func deleteChildValue(child interface{}, remainingPaths []string) interface{} {
|
||||||
|
log.Debugf("deleteChildValue for %v for %v\n", remainingPaths, child)
|
||||||
|
|
||||||
|
idx, nextIndexErr := strconv.ParseInt(remainingPaths[0], 10, 64)
|
||||||
|
if nextIndexErr != nil {
|
||||||
|
// must be a map
|
||||||
|
log.Debugf("\tdetected a map, invoking deleteMap\n")
|
||||||
|
return deleteMap(child, remainingPaths)
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Debugf("\tdetected an array, so traversing element with index %d\n", idx)
|
||||||
|
return deleteArray(child, remainingPaths, idx)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,21 +2,11 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"gopkg.in/yaml.v2"
|
|
||||||
"os"
|
|
||||||
"sort"
|
"sort"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
|
||||||
|
|
||||||
func parseData(rawData string) map[interface{}]interface{} {
|
yaml "gopkg.in/mikefarah/yaml.v2"
|
||||||
var parsedData map[interface{}]interface{}
|
)
|
||||||
err := yaml.Unmarshal([]byte(rawData), &parsedData)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println("Error parsing yaml: %v", err)
|
|
||||||
os.Exit(1)
|
|
||||||
}
|
|
||||||
return parsedData
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestReadMap_simple(t *testing.T) {
|
func TestReadMap_simple(t *testing.T) {
|
||||||
var data = parseData(`
|
var data = parseData(`
|
||||||
@@ -24,7 +14,8 @@ func TestReadMap_simple(t *testing.T) {
|
|||||||
b:
|
b:
|
||||||
c: 2
|
c: 2
|
||||||
`)
|
`)
|
||||||
assertResult(t, 2, readMap(data, "b", []string{"c"}))
|
got, _ := readMap(data, "b", []string{"c"})
|
||||||
|
assertResult(t, 2, got)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestReadMap_splat(t *testing.T) {
|
func TestReadMap_splat(t *testing.T) {
|
||||||
@@ -34,7 +25,8 @@ mapSplat:
|
|||||||
item1: things
|
item1: things
|
||||||
item2: whatever
|
item2: whatever
|
||||||
`)
|
`)
|
||||||
var result = readMap(data, "mapSplat", []string{"*"}).([]interface{})
|
res, _ := readMap(data, "mapSplat", []string{"*"})
|
||||||
|
result := res.([]interface{})
|
||||||
var actual = []string{result[0].(string), result[1].(string)}
|
var actual = []string{result[0].(string), result[1].(string)}
|
||||||
sort.Strings(actual)
|
sort.Strings(actual)
|
||||||
assertResult(t, "[things whatever]", fmt.Sprintf("%v", actual))
|
assertResult(t, "[things whatever]", fmt.Sprintf("%v", actual))
|
||||||
@@ -50,7 +42,8 @@ mapSplatDeep:
|
|||||||
cats: apples
|
cats: apples
|
||||||
`)
|
`)
|
||||||
|
|
||||||
var result = readMap(data, "mapSplatDeep", []string{"*", "cats"}).([]interface{})
|
res, _ := readMap(data, "mapSplatDeep", []string{"*", "cats"})
|
||||||
|
result := res.([]interface{})
|
||||||
var actual = []string{result[0].(string), result[1].(string)}
|
var actual = []string{result[0].(string), result[1].(string)}
|
||||||
sort.Strings(actual)
|
sort.Strings(actual)
|
||||||
assertResult(t, "[apples bananas]", fmt.Sprintf("%v", actual))
|
assertResult(t, "[apples bananas]", fmt.Sprintf("%v", actual))
|
||||||
@@ -62,7 +55,8 @@ func TestReadMap_key_doesnt_exist(t *testing.T) {
|
|||||||
b:
|
b:
|
||||||
c: 2
|
c: 2
|
||||||
`)
|
`)
|
||||||
assertResult(t, nil, readMap(data, "b.x.f", []string{"c"}))
|
got, _ := readMap(data, "b.x.f", []string{"c"})
|
||||||
|
assertResult(t, nil, got)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestReadMap_recurse_against_string(t *testing.T) {
|
func TestReadMap_recurse_against_string(t *testing.T) {
|
||||||
@@ -70,7 +64,8 @@ func TestReadMap_recurse_against_string(t *testing.T) {
|
|||||||
---
|
---
|
||||||
a: cat
|
a: cat
|
||||||
`)
|
`)
|
||||||
assertResult(t, nil, readMap(data, "a", []string{"b"}))
|
got, _ := readMap(data, "a", []string{"b"})
|
||||||
|
assertResult(t, nil, got)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestReadMap_with_array(t *testing.T) {
|
func TestReadMap_with_array(t *testing.T) {
|
||||||
@@ -81,7 +76,64 @@ b:
|
|||||||
- 3
|
- 3
|
||||||
- 4
|
- 4
|
||||||
`)
|
`)
|
||||||
assertResult(t, 4, readMap(data, "b", []string{"d", "1"}))
|
got, _ := readMap(data, "b", []string{"d", "1"})
|
||||||
|
assertResult(t, 4, got)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestReadMap_with_array_and_bad_index(t *testing.T) {
|
||||||
|
var data = parseData(`
|
||||||
|
---
|
||||||
|
b:
|
||||||
|
d:
|
||||||
|
- 3
|
||||||
|
- 4
|
||||||
|
`)
|
||||||
|
_, err := readMap(data, "b", []string{"d", "x"})
|
||||||
|
if err == nil {
|
||||||
|
t.Fatal("Expected error due to invalid path")
|
||||||
|
}
|
||||||
|
expectedOutput := `Error accessing array: strconv.ParseInt: parsing "x": invalid syntax`
|
||||||
|
assertResult(t, expectedOutput, err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestReadMap_with_mapsplat_array_and_bad_index(t *testing.T) {
|
||||||
|
var data = parseData(`
|
||||||
|
---
|
||||||
|
b:
|
||||||
|
d:
|
||||||
|
e:
|
||||||
|
- 3
|
||||||
|
- 4
|
||||||
|
f:
|
||||||
|
- 1
|
||||||
|
- 2
|
||||||
|
`)
|
||||||
|
_, err := readMap(data, "b", []string{"d", "*", "x"})
|
||||||
|
if err == nil {
|
||||||
|
t.Fatal("Expected error due to invalid path")
|
||||||
|
}
|
||||||
|
expectedOutput := `Error accessing array: strconv.ParseInt: parsing "x": invalid syntax`
|
||||||
|
assertResult(t, expectedOutput, err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestReadMap_with_arraysplat_map_array_and_bad_index(t *testing.T) {
|
||||||
|
var data = parseData(`
|
||||||
|
---
|
||||||
|
b:
|
||||||
|
d:
|
||||||
|
- names:
|
||||||
|
- fred
|
||||||
|
- smith
|
||||||
|
- names:
|
||||||
|
- sam
|
||||||
|
- bo
|
||||||
|
`)
|
||||||
|
_, err := readMap(data, "b", []string{"d", "*", "names", "x"})
|
||||||
|
if err == nil {
|
||||||
|
t.Fatal("Expected error due to invalid path")
|
||||||
|
}
|
||||||
|
expectedOutput := `Error accessing array: strconv.ParseInt: parsing "x": invalid syntax`
|
||||||
|
assertResult(t, expectedOutput, err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestReadMap_with_array_out_of_bounds(t *testing.T) {
|
func TestReadMap_with_array_out_of_bounds(t *testing.T) {
|
||||||
@@ -92,7 +144,20 @@ b:
|
|||||||
- 3
|
- 3
|
||||||
- 4
|
- 4
|
||||||
`)
|
`)
|
||||||
assertResult(t, nil, readMap(data, "b", []string{"d", "3"}))
|
got, _ := readMap(data, "b", []string{"d", "3"})
|
||||||
|
assertResult(t, nil, got)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestReadMap_with_array_out_of_bounds_by_1(t *testing.T) {
|
||||||
|
var data = parseData(`
|
||||||
|
---
|
||||||
|
b:
|
||||||
|
d:
|
||||||
|
- 3
|
||||||
|
- 4
|
||||||
|
`)
|
||||||
|
got, _ := readMap(data, "b", []string{"d", "2"})
|
||||||
|
assertResult(t, nil, got)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestReadMap_with_array_splat(t *testing.T) {
|
func TestReadMap_with_array_splat(t *testing.T) {
|
||||||
@@ -105,7 +170,18 @@ e:
|
|||||||
name: Sam
|
name: Sam
|
||||||
thing: dog
|
thing: dog
|
||||||
`)
|
`)
|
||||||
assertResult(t, "[Fred Sam]", fmt.Sprintf("%v", readMap(data, "e", []string{"*", "name"})))
|
got, _ := readMap(data, "e", []string{"*", "name"})
|
||||||
|
assertResult(t, "[Fred Sam]", fmt.Sprintf("%v", got))
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestWrite_really_simple(t *testing.T) {
|
||||||
|
var data = parseData(`
|
||||||
|
b: 2
|
||||||
|
`)
|
||||||
|
|
||||||
|
updated := writeMap(data, []string{"b"}, "4")
|
||||||
|
b := entryInSlice(updated, "b").Value
|
||||||
|
assertResult(t, "4", b)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestWrite_simple(t *testing.T) {
|
func TestWrite_simple(t *testing.T) {
|
||||||
@@ -114,10 +190,96 @@ b:
|
|||||||
c: 2
|
c: 2
|
||||||
`)
|
`)
|
||||||
|
|
||||||
write(data, "b", []string{"c"}, "4")
|
updated := writeMap(data, []string{"b", "c"}, "4")
|
||||||
|
b := entryInSlice(updated, "b").Value.(yaml.MapSlice)
|
||||||
|
c := entryInSlice(b, "c").Value
|
||||||
|
assertResult(t, "4", c)
|
||||||
|
}
|
||||||
|
|
||||||
b := data["b"].(map[interface{}]interface{})
|
func TestWrite_new(t *testing.T) {
|
||||||
assertResult(t, "4", b["c"].(string))
|
var data = parseData(`
|
||||||
|
b:
|
||||||
|
c: 2
|
||||||
|
`)
|
||||||
|
|
||||||
|
updated := writeMap(data, []string{"b", "d"}, "4")
|
||||||
|
b := entryInSlice(updated, "b").Value.(yaml.MapSlice)
|
||||||
|
d := entryInSlice(b, "d").Value
|
||||||
|
assertResult(t, "4", d)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestWrite_new_deep(t *testing.T) {
|
||||||
|
var data = parseData(`
|
||||||
|
b:
|
||||||
|
c: 2
|
||||||
|
`)
|
||||||
|
|
||||||
|
updated := writeMap(data, []string{"b", "d", "f"}, "4")
|
||||||
|
got, _ := readMap(updated, "b", []string{"d", "f"})
|
||||||
|
assertResult(t, "4", got)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestWrite_array(t *testing.T) {
|
||||||
|
var data = parseData(`
|
||||||
|
b:
|
||||||
|
- aa
|
||||||
|
`)
|
||||||
|
|
||||||
|
updated := writeMap(data, []string{"b", "0"}, "bb")
|
||||||
|
|
||||||
|
b := entryInSlice(updated, "b").Value.([]interface{})
|
||||||
|
assertResult(t, "bb", b[0].(string))
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestWrite_new_array(t *testing.T) {
|
||||||
|
var data = parseData(`
|
||||||
|
b:
|
||||||
|
c: 2
|
||||||
|
`)
|
||||||
|
|
||||||
|
updated := writeMap(data, []string{"b", "0"}, "4")
|
||||||
|
got, _ := readMap(updated, "b", []string{"0"})
|
||||||
|
assertResult(t, "4", got)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestWrite_new_array_deep(t *testing.T) {
|
||||||
|
var data = parseData(`
|
||||||
|
b:
|
||||||
|
c: 2
|
||||||
|
`)
|
||||||
|
|
||||||
|
var expected = `b:
|
||||||
|
- c: "4"`
|
||||||
|
|
||||||
|
updated := writeMap(data, []string{"b", "0", "c"}, "4")
|
||||||
|
got, _ := yamlToString(updated)
|
||||||
|
assertResult(t, expected, got)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestWrite_new_map_array_deep(t *testing.T) {
|
||||||
|
var data = parseData(`
|
||||||
|
b:
|
||||||
|
c: 2
|
||||||
|
`)
|
||||||
|
|
||||||
|
updated := writeMap(data, []string{"b", "d", "0"}, "4")
|
||||||
|
got, _ := readMap(updated, "b", []string{"d", "0"})
|
||||||
|
assertResult(t, "4", got)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestWrite_add_to_array(t *testing.T) {
|
||||||
|
var data = parseData(`
|
||||||
|
b:
|
||||||
|
- aa
|
||||||
|
`)
|
||||||
|
|
||||||
|
var expected = `b:
|
||||||
|
- aa
|
||||||
|
- bb`
|
||||||
|
|
||||||
|
updated := writeMap(data, []string{"b", "1"}, "bb")
|
||||||
|
got, _ := yamlToString(updated)
|
||||||
|
assertResult(t, expected, got)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestWrite_with_no_tail(t *testing.T) {
|
func TestWrite_with_no_tail(t *testing.T) {
|
||||||
@@ -125,22 +287,101 @@ func TestWrite_with_no_tail(t *testing.T) {
|
|||||||
b:
|
b:
|
||||||
c: 2
|
c: 2
|
||||||
`)
|
`)
|
||||||
write(data, "b", []string{}, "4")
|
updated := writeMap(data, []string{"b"}, "4")
|
||||||
|
|
||||||
b := data["b"]
|
b := entryInSlice(updated, "b").Value
|
||||||
assertResult(t, "4", fmt.Sprintf("%v", b))
|
assertResult(t, "4", fmt.Sprintf("%v", b))
|
||||||
}
|
}
|
||||||
|
|
||||||
func assertResult(t *testing.T, expectedValue interface{}, actualValue interface{}) {
|
func TestWriteMap_no_paths(t *testing.T) {
|
||||||
if expectedValue != actualValue {
|
var data = parseData(`
|
||||||
t.Error("Expected <", expectedValue, "> but got <", actualValue, ">", fmt.Sprintf("%T", actualValue))
|
b: 5
|
||||||
}
|
`)
|
||||||
|
|
||||||
|
result := writeMap(data, []string{}, 4)
|
||||||
|
assertResult(t, fmt.Sprintf("%v", data), fmt.Sprintf("%v", result))
|
||||||
}
|
}
|
||||||
|
|
||||||
func assertResultWithContext(t *testing.T, expectedValue interface{}, actualValue interface{}, context interface{}) {
|
func TestWriteArray_no_paths(t *testing.T) {
|
||||||
|
var data = make([]interface{}, 1)
|
||||||
if expectedValue != actualValue {
|
data[0] = "mike"
|
||||||
t.Error(context)
|
result := writeArray(data, []string{}, 4)
|
||||||
t.Error(": expected <", expectedValue, "> but got <", actualValue, ">")
|
assertResult(t, fmt.Sprintf("%v", data), fmt.Sprintf("%v", result))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestDelete_MapItem(t *testing.T) {
|
||||||
|
var data = parseData(`
|
||||||
|
a: 123
|
||||||
|
b: 456
|
||||||
|
`)
|
||||||
|
var expected = parseData(`
|
||||||
|
b: 456
|
||||||
|
`)
|
||||||
|
|
||||||
|
result := deleteMap(data, []string{"a"})
|
||||||
|
assertResult(t, fmt.Sprintf("%v", expected), fmt.Sprintf("%v", result))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ensure deleting an index into a string does nothing
|
||||||
|
func TestDelete_index_to_string(t *testing.T) {
|
||||||
|
var data = parseData(`
|
||||||
|
a: mystring
|
||||||
|
`)
|
||||||
|
result := deleteMap(data, []string{"a", "0"})
|
||||||
|
assertResult(t, fmt.Sprintf("%v", data), fmt.Sprintf("%v", result))
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestDelete_list_index(t *testing.T) {
|
||||||
|
var data = parseData(`
|
||||||
|
a: [3, 4]
|
||||||
|
`)
|
||||||
|
var expected = parseData(`
|
||||||
|
a: [3]
|
||||||
|
`)
|
||||||
|
result := deleteMap(data, []string{"a", "1"})
|
||||||
|
assertResult(t, fmt.Sprintf("%v", expected), fmt.Sprintf("%v", result))
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestDelete_list_index_beyond_bounds(t *testing.T) {
|
||||||
|
var data = parseData(`
|
||||||
|
a: [3, 4]
|
||||||
|
`)
|
||||||
|
result := deleteMap(data, []string{"a", "5"})
|
||||||
|
assertResult(t, fmt.Sprintf("%v", data), fmt.Sprintf("%v", result))
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestDelete_list_index_out_of_bounds_by_1(t *testing.T) {
|
||||||
|
var data = parseData(`
|
||||||
|
a: [3, 4]
|
||||||
|
`)
|
||||||
|
result := deleteMap(data, []string{"a", "2"})
|
||||||
|
assertResult(t, fmt.Sprintf("%v", data), fmt.Sprintf("%v", result))
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestDelete_no_paths(t *testing.T) {
|
||||||
|
var data = parseData(`
|
||||||
|
a: [3, 4]
|
||||||
|
b:
|
||||||
|
- name: test
|
||||||
|
`)
|
||||||
|
result := deleteMap(data, []string{})
|
||||||
|
assertResult(t, fmt.Sprintf("%v", data), fmt.Sprintf("%v", result))
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestDelete_array_map_item(t *testing.T) {
|
||||||
|
var data = parseData(`
|
||||||
|
b:
|
||||||
|
- name: fred
|
||||||
|
value: blah
|
||||||
|
- name: john
|
||||||
|
value: test
|
||||||
|
`)
|
||||||
|
var expected = parseData(`
|
||||||
|
b:
|
||||||
|
- value: blah
|
||||||
|
- name: john
|
||||||
|
value: test
|
||||||
|
`)
|
||||||
|
result := deleteMap(data, []string{"b", "0", "name"})
|
||||||
|
assertResult(t, fmt.Sprintf("%v", expected), fmt.Sprintf("%v", result))
|
||||||
}
|
}
|
||||||
|
|||||||
12
debian/changelog
vendored
Normal file
12
debian/changelog
vendored
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
yq (2.0-0) bionic; urgency=medium
|
||||||
|
|
||||||
|
* Release 2.0.0
|
||||||
|
|
||||||
|
-- Roberto Mier Escandón <rmescandon@gmail.com> Wed, 20 Jun 2018 10:29:53 +0200
|
||||||
|
|
||||||
|
yq (1.15-0) bionic; urgency=medium
|
||||||
|
|
||||||
|
* Release 1.15
|
||||||
|
|
||||||
|
-- Roberto Mier Escandón <rmescandon@gmail.com> Wed, 06 Jun 2018 11:32:03 +0200
|
||||||
|
|
||||||
1
debian/compat
vendored
Normal file
1
debian/compat
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
9
|
||||||
22
debian/control
vendored
Normal file
22
debian/control
vendored
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
Source: yq
|
||||||
|
Section: devel
|
||||||
|
Priority: extra
|
||||||
|
Maintainer: Roberto Mier Escandón <rmescandon@gmail.com>
|
||||||
|
Build-Depends: debhelper (>= 9),
|
||||||
|
dh-golang,
|
||||||
|
golang-1.10-go,
|
||||||
|
rsync
|
||||||
|
Standards-Version: 3.9.6
|
||||||
|
Homepage: https://github.com/mikefarah/yq.git
|
||||||
|
Vcs-Browser: https://github.com/mikefarah/yq.git
|
||||||
|
Vcs-Git: https://github.com/mikefarah/yq.git
|
||||||
|
|
||||||
|
Package: yq
|
||||||
|
Architecture: all
|
||||||
|
Built-Using: ${misc:Built-Using}
|
||||||
|
Depends: ${shlibs:Depends},
|
||||||
|
${misc:Depends}
|
||||||
|
Description:
|
||||||
|
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
debian/copyright
vendored
Normal file
7
debian/copyright
vendored
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
|
||||||
|
Upstream-Name: yq
|
||||||
|
Source: https://github.com/mikefarah/yq.git
|
||||||
|
|
||||||
|
Files: *
|
||||||
|
Copyright: 2017 Mike Farah Ltd. All rights reserved
|
||||||
|
License: Proprietary
|
||||||
2
debian/gbp.conf
vendored
Normal file
2
debian/gbp.conf
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
[DEFAULT]
|
||||||
|
pristine-tar = True
|
||||||
59
debian/rules
vendored
Executable file
59
debian/rules
vendored
Executable file
@@ -0,0 +1,59 @@
|
|||||||
|
#!/usr/bin/make -f
|
||||||
|
#
|
||||||
|
# Copyright (C) 2018 Roberto Mier Escandón <rmescandon@gmail.com>
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License version 3 as
|
||||||
|
# published by the Free Software Foundation.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
|
||||||
|
PROJECT := yq
|
||||||
|
OWNER := mikefarah
|
||||||
|
REPO := github.com
|
||||||
|
GOVERSION := 1.10
|
||||||
|
export DH_OPTIONS
|
||||||
|
export DH_GOPKG := ${REPO}/${OWNER}/${PROJECT}
|
||||||
|
export GOROOT := /usr/lib/go-${GOVERSION}
|
||||||
|
export GOPATH := ${CURDIR}/_build
|
||||||
|
export GOBIN := ${GOPATH}/bin
|
||||||
|
export PATH := ${GOROOT}/bin:${GOBIN}:${PATH}
|
||||||
|
BLDPATH := $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
|
||||||
|
SRCDIR := ${CURDIR}/_build/src/${DH_GOPKG}
|
||||||
|
DESTDIR := ${CURDIR}/debian/${PROJECT}
|
||||||
|
BINDIR := /usr/bin
|
||||||
|
ASSETSDIR := /usr/share/${PROJECT}
|
||||||
|
|
||||||
|
%:
|
||||||
|
dh $@ --buildsystem=golang --with=golang
|
||||||
|
|
||||||
|
override_dh_auto_build:
|
||||||
|
mkdir -p ${SRCDIR}
|
||||||
|
mkdir -p ${GOBIN}
|
||||||
|
# copy project to local srcdir to build from there
|
||||||
|
rsync -avz --progress --exclude=obj-${BLDPATH} --exclude=debian . $(SRCDIR)
|
||||||
|
# build go code
|
||||||
|
(cd ${SRCDIR} && go install ./...)
|
||||||
|
|
||||||
|
override_dh_auto_test:
|
||||||
|
(cd ${SRCDIR} && go test -v ./...)
|
||||||
|
|
||||||
|
override_dh_auto_install:
|
||||||
|
mkdir -p ${DESTDIR}/${BINDIR}
|
||||||
|
mkdir -p ${DESTDIR}/${ASSETSDIR}
|
||||||
|
cp ${CURDIR}/_build/bin/yq ${DESTDIR}/${BINDIR}
|
||||||
|
cp -rf ${SRCDIR}/LICENSE ${DESTDIR}/${ASSETSDIR}
|
||||||
|
cp -rf ${SRCDIR}/README.md ${DESTDIR}/${PLUGINSDIR}
|
||||||
|
chmod a+x ${DESTDIR}/${BINDIR}/yq
|
||||||
|
|
||||||
|
override_dh_auto_clean:
|
||||||
|
dh_clean
|
||||||
|
rm -rf ${CURDIR}/obj-${BLDPATH}
|
||||||
|
rm -rf ${CURDIR}/_build
|
||||||
1
debian/source/format
vendored
Normal file
1
debian/source/format
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
3.0 (native)
|
||||||
346
docs/404.html
Normal file
346
docs/404.html
Normal file
@@ -0,0 +1,346 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en" class="no-js">
|
||||||
|
<head>
|
||||||
|
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||||
|
<meta http-equiv="x-ua-compatible" content="ie=edge">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<meta name="lang:clipboard.copy" content="Copy to clipboard">
|
||||||
|
|
||||||
|
<meta name="lang:clipboard.copied" content="Copied to clipboard">
|
||||||
|
|
||||||
|
<meta name="lang:search.language" content="en">
|
||||||
|
|
||||||
|
<meta name="lang:search.result.none" content="No matching documents">
|
||||||
|
|
||||||
|
<meta name="lang:search.result.one" content="1 matching document">
|
||||||
|
|
||||||
|
<meta name="lang:search.result.other" content="# matching documents">
|
||||||
|
|
||||||
|
<meta name="lang:search.tokenizer" content="[\s\-]+">
|
||||||
|
|
||||||
|
<link rel="shortcut icon" href="/assets/images/favicon.png">
|
||||||
|
<meta name="generator" content="mkdocs-0.17.2, mkdocs-material-2.2.5">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<title>Yq</title>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<link rel="stylesheet" href="/assets/stylesheets/application.bcabdff3.css">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<script src="/assets/javascripts/modernizr.1aa3b519.js"></script>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,400i,700|Roboto+Mono">
|
||||||
|
<style>body,input{font-family:"Roboto","Helvetica Neue",Helvetica,Arial,sans-serif}code,kbd,pre{font-family:"Roboto Mono","Courier New",Courier,monospace}</style>
|
||||||
|
|
||||||
|
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<svg class="md-svg">
|
||||||
|
<defs>
|
||||||
|
|
||||||
|
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="416" height="448" viewBox="0 0 416 448" id="github"><path fill="currentColor" d="M160 304q0 10-3.125 20.5t-10.75 19T128 352t-18.125-8.5-10.75-19T96 304t3.125-20.5 10.75-19T128 256t18.125 8.5 10.75 19T160 304zm160 0q0 10-3.125 20.5t-10.75 19T288 352t-18.125-8.5-10.75-19T256 304t3.125-20.5 10.75-19T288 256t18.125 8.5 10.75 19T320 304zm40 0q0-30-17.25-51T296 232q-10.25 0-48.75 5.25Q229.5 240 208 240t-39.25-2.75Q130.75 232 120 232q-29.5 0-46.75 21T56 304q0 22 8 38.375t20.25 25.75 30.5 15 35 7.375 37.25 1.75h42q20.5 0 37.25-1.75t35-7.375 30.5-15 20.25-25.75T360 304zm56-44q0 51.75-15.25 82.75-9.5 19.25-26.375 33.25t-35.25 21.5-42.5 11.875-42.875 5.5T212 416q-19.5 0-35.5-.75t-36.875-3.125-38.125-7.5-34.25-12.875T37 371.5t-21.5-28.75Q0 312 0 260q0-59.25 34-99-6.75-20.5-6.75-42.5 0-29 12.75-54.5 27 0 47.5 9.875t47.25 30.875Q171.5 96 212 96q37 0 70 8 26.25-20.5 46.75-30.25T376 64q12.75 25.5 12.75 54.5 0 21.75-6.75 42 34 40 34 99.5z"/></svg>
|
||||||
|
|
||||||
|
</defs>
|
||||||
|
</svg>
|
||||||
|
<input class="md-toggle" data-md-toggle="drawer" type="checkbox" id="drawer">
|
||||||
|
<input class="md-toggle" data-md-toggle="search" type="checkbox" id="search">
|
||||||
|
<label class="md-overlay" data-md-component="overlay" for="drawer"></label>
|
||||||
|
|
||||||
|
<header class="md-header" data-md-component="header">
|
||||||
|
<nav class="md-header-nav md-grid">
|
||||||
|
<div class="md-flex">
|
||||||
|
<div class="md-flex__cell md-flex__cell--shrink">
|
||||||
|
<a href="/" title="Yq" class="md-header-nav__button md-logo">
|
||||||
|
|
||||||
|
<i class="md-icon"></i>
|
||||||
|
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<div class="md-flex__cell md-flex__cell--shrink">
|
||||||
|
<label class="md-icon md-icon--menu md-header-nav__button" for="drawer"></label>
|
||||||
|
</div>
|
||||||
|
<div class="md-flex__cell md-flex__cell--stretch">
|
||||||
|
<div class="md-flex__ellipsis md-header-nav__title" data-md-component="title">
|
||||||
|
|
||||||
|
|
||||||
|
<span class="md-header-nav__topic">
|
||||||
|
Yq
|
||||||
|
</span>
|
||||||
|
<span class="md-header-nav__topic">
|
||||||
|
|
||||||
|
</span>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="md-flex__cell md-flex__cell--shrink">
|
||||||
|
|
||||||
|
|
||||||
|
<label class="md-icon md-icon--search md-header-nav__button" for="search"></label>
|
||||||
|
|
||||||
|
<div class="md-search" data-md-component="search" role="dialog">
|
||||||
|
<label class="md-search__overlay" for="search"></label>
|
||||||
|
<div class="md-search__inner">
|
||||||
|
<form class="md-search__form" name="search">
|
||||||
|
<input type="text" class="md-search__input" name="query" required placeholder="Search" autocapitalize="off" autocorrect="off" autocomplete="off" spellcheck="false" data-md-component="query">
|
||||||
|
<label class="md-icon md-search__icon" for="search"></label>
|
||||||
|
<button type="reset" class="md-icon md-search__icon" data-md-component="reset"></button>
|
||||||
|
</form>
|
||||||
|
<div class="md-search__output">
|
||||||
|
<div class="md-search__scrollwrap" data-md-scrollfix>
|
||||||
|
<div class="md-search-result" data-md-component="result">
|
||||||
|
<div class="md-search-result__meta">
|
||||||
|
Type to start searching
|
||||||
|
</div>
|
||||||
|
<ol class="md-search-result__list"></ol>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="md-flex__cell md-flex__cell--shrink">
|
||||||
|
<div class="md-header-nav__source">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<a href="https://github.com/mikefarah/yq/" title="Go to repository" class="md-source" data-md-source="github">
|
||||||
|
|
||||||
|
<div class="md-source__icon">
|
||||||
|
<svg viewBox="0 0 24 24" width="24" height="24">
|
||||||
|
<use xlink:href="#github" width="24" height="24"></use>
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="md-source__repository">
|
||||||
|
mikefarah/yq
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<div class="md-container">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<main class="md-main">
|
||||||
|
<div class="md-main__inner md-grid" data-md-component="container">
|
||||||
|
|
||||||
|
|
||||||
|
<div class="md-sidebar md-sidebar--primary" data-md-component="navigation">
|
||||||
|
<div class="md-sidebar__scrollwrap">
|
||||||
|
<div class="md-sidebar__inner">
|
||||||
|
<nav class="md-nav md-nav--primary" data-md-level="0">
|
||||||
|
<label class="md-nav__title md-nav__title--site" for="drawer">
|
||||||
|
<span class="md-nav__button md-logo">
|
||||||
|
|
||||||
|
<i class="md-icon"></i>
|
||||||
|
|
||||||
|
</span>
|
||||||
|
Yq
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<div class="md-nav__source">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<a href="https://github.com/mikefarah/yq/" title="Go to repository" class="md-source" data-md-source="github">
|
||||||
|
|
||||||
|
<div class="md-source__icon">
|
||||||
|
<svg viewBox="0 0 24 24" width="24" height="24">
|
||||||
|
<use xlink:href="#github" width="24" height="24"></use>
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="md-source__repository">
|
||||||
|
mikefarah/yq
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<ul class="md-nav__list" data-md-scrollfix>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="/" title="Install" class="md-nav__link">
|
||||||
|
Install
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="/read/" title="Read" class="md-nav__link">
|
||||||
|
Read
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="/write/" title="Write/Update" class="md-nav__link">
|
||||||
|
Write/Update
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="/delete/" title="Delete" class="md-nav__link">
|
||||||
|
Delete
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="/create/" title="Create" class="md-nav__link">
|
||||||
|
Create
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="/convert/" title="Convert" class="md-nav__link">
|
||||||
|
Convert
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="/merge/" title="Merge" class="md-nav__link">
|
||||||
|
Merge
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
|
||||||
|
</ul>
|
||||||
|
</nav>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div class="md-content">
|
||||||
|
<article class="md-content__inner md-typeset">
|
||||||
|
|
||||||
|
<h1>404 - Not found</h1>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</article>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
|
||||||
|
|
||||||
|
<footer class="md-footer">
|
||||||
|
|
||||||
|
<div class="md-footer-meta md-typeset">
|
||||||
|
<div class="md-footer-meta__inner md-grid">
|
||||||
|
<div class="md-footer-copyright">
|
||||||
|
|
||||||
|
powered by
|
||||||
|
<a href="http://www.mkdocs.org">MkDocs</a>
|
||||||
|
and
|
||||||
|
<a href="https://squidfunk.github.io/mkdocs-material/">
|
||||||
|
Material for MkDocs</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="md-footer-social">
|
||||||
|
|
||||||
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
|
||||||
|
|
||||||
|
<a href="https://github.com/mikefarah" class="md-footer-social__link fa fa-github"></a>
|
||||||
|
|
||||||
|
<a href="https://www.linkedin.com/in/mike-farah-b5a75b2/" class="md-footer-social__link fa fa-linkedin"></a>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</footer>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script src="/assets/javascripts/application.6cdc17f0.js"></script>
|
||||||
|
|
||||||
|
<script>app.initialize({version:"0.17.2",url:{base:""}})</script>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
BIN
docs/assets/images/favicon.png
Normal file
BIN
docs/assets/images/favicon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 521 B |
1
docs/assets/images/icons/bitbucket.4ebea66e.svg
Normal file
1
docs/assets/images/icons/bitbucket.4ebea66e.svg
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="352" height="448" viewBox="0 0 352 448" id="bitbucket"><path fill="currentColor" d="M203.75 214.75q2 15.75-12.625 25.25t-27.875 1.5q-9.75-4.25-13.375-14.5t-.125-20.5 13-14.5q9-4.5 18.125-3t16 8.875 6.875 16.875zm27.75-5.25q-3.5-26.75-28.25-41T154 165.25q-15.75 7-25.125 22.125t-8.625 32.375q1 22.75 19.375 38.75t41.375 14q22.75-2 38-21t12.5-42zM291.25 74q-5-6.75-14-11.125t-14.5-5.5T245 54.25q-72.75-11.75-141.5.5-10.75 1.75-16.5 3t-13.75 5.5T60.75 74q7.5 7 19 11.375t18.375 5.5T120 93.75Q177 101 232 94q15.75-2 22.375-3t18.125-5.375T291.25 74zm14.25 258.75q-2 6.5-3.875 19.125t-3.5 21-7.125 17.5-14.5 14.125q-21.5 12-47.375 17.875t-50.5 5.5-50.375-4.625q-11.5-2-20.375-4.5T88.75 412 70.5 401.125t-13-15.375q-6.25-24-14.25-73l1.5-4 4.5-2.25q55.75 37 126.625 37t126.875-37q5.25 1.5 6 5.75t-1.25 11.25-2 9.25zM350.75 92.5q-6.5 41.75-27.75 163.75-1.25 7.5-6.75 14t-10.875 10T291.75 288q-63 31.5-152.5 22-62-6.75-98.5-34.75-3.75-3-6.375-6.625t-4.25-8.75-2.25-8.5-1.5-9.875T25 232.75q-2.25-12.5-6.625-37.5t-7-40.375T5.5 118 0 78.5Q.75 72 4.375 66.375T12.25 57t11.25-7.5T35 43.875t12-4.625q31.25-11.5 78.25-16 94.75-9.25 169 12.5Q333 47.25 348 66.25q4 5 4.125 12.75t-1.375 13.5z"/></svg>
|
||||||
|
After Width: | Height: | Size: 1.2 KiB |
1
docs/assets/images/icons/github.a4034fb1.svg
Normal file
1
docs/assets/images/icons/github.a4034fb1.svg
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="416" height="448" viewBox="0 0 416 448" id="github"><path fill="currentColor" d="M160 304q0 10-3.125 20.5t-10.75 19T128 352t-18.125-8.5-10.75-19T96 304t3.125-20.5 10.75-19T128 256t18.125 8.5 10.75 19T160 304zm160 0q0 10-3.125 20.5t-10.75 19T288 352t-18.125-8.5-10.75-19T256 304t3.125-20.5 10.75-19T288 256t18.125 8.5 10.75 19T320 304zm40 0q0-30-17.25-51T296 232q-10.25 0-48.75 5.25Q229.5 240 208 240t-39.25-2.75Q130.75 232 120 232q-29.5 0-46.75 21T56 304q0 22 8 38.375t20.25 25.75 30.5 15 35 7.375 37.25 1.75h42q20.5 0 37.25-1.75t35-7.375 30.5-15 20.25-25.75T360 304zm56-44q0 51.75-15.25 82.75-9.5 19.25-26.375 33.25t-35.25 21.5-42.5 11.875-42.875 5.5T212 416q-19.5 0-35.5-.75t-36.875-3.125-38.125-7.5-34.25-12.875T37 371.5t-21.5-28.75Q0 312 0 260q0-59.25 34-99-6.75-20.5-6.75-42.5 0-29 12.75-54.5 27 0 47.5 9.875t47.25 30.875Q171.5 96 212 96q37 0 70 8 26.25-20.5 46.75-30.25T376 64q12.75 25.5 12.75 54.5 0 21.75-6.75 42 34 40 34 99.5z"/></svg>
|
||||||
|
After Width: | Height: | Size: 991 B |
1
docs/assets/images/icons/gitlab.d80e5efc.svg
Normal file
1
docs/assets/images/icons/gitlab.d80e5efc.svg
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="500" height="500" viewBox="0 0 500 500" id="gitlab"><path fill="currentColor" d="M93.667 473.347l90.684-279.097H2.983l90.684 279.097z" transform="translate(156.198 1.16)"/><path fill="currentColor" d="M221.333 473.345L130.649 194.25H3.557l217.776 279.095z" transform="translate(28.531 1.16)" opacity=".7"/><path fill="currentColor" d="M32 195.155L4.441 279.97a18.773 18.773 0 0 0 6.821 20.99l238.514 173.29L32 195.155z" transform="translate(.089 .256)" opacity=".5"/><path fill="currentColor" d="M2.667-84.844h127.092L75.14-252.942c-2.811-8.649-15.047-8.649-17.856 0L2.667-84.844z" transform="translate(29.422 280.256)"/><path fill="currentColor" d="M2.667 473.345L93.351 194.25h127.092L2.667 473.345z" transform="translate(247.198 1.16)" opacity=".7"/><path fill="currentColor" d="M221.334 195.155l27.559 84.815a18.772 18.772 0 0 1-6.821 20.99L3.557 474.25l217.777-279.095z" transform="translate(246.307 .256)" opacity=".5"/><path fill="currentColor" d="M130.667-84.844H3.575l54.618-168.098c2.811-8.649 15.047-8.649 17.856 0l54.618 168.098z" transform="translate(336.974 280.256)"/></svg>
|
||||||
|
After Width: | Height: | Size: 1.1 KiB |
1
docs/assets/javascripts/application.6cdc17f0.js
Normal file
1
docs/assets/javascripts/application.6cdc17f0.js
Normal file
File diff suppressed because one or more lines are too long
1
docs/assets/javascripts/lunr/lunr.da.js
Normal file
1
docs/assets/javascripts/lunr/lunr.da.js
Normal file
@@ -0,0 +1 @@
|
|||||||
|
!function(e,r){"function"==typeof define&&define.amd?define(r):"object"==typeof exports?module.exports=r():r()(e.lunr)}(this,function(){return function(e){if(void 0===e)throw new Error("Lunr is not present. Please include / require Lunr before this script.");if(void 0===e.stemmerSupport)throw new Error("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(){var r=e.stemmerSupport.Among,i=e.stemmerSupport.SnowballProgram,n=new function(){function e(){var e,r=l.limit-l.cursor;l.cursor>=t&&(e=l.limit_backward,l.limit_backward=t,l.ket=l.cursor,l.find_among_b(a,4)?(l.bra=l.cursor,l.limit_backward=e,l.cursor=l.limit-r,l.cursor>l.limit_backward&&(l.cursor--,l.bra=l.cursor,l.slice_del())):l.limit_backward=e)}var n,t,s,o=[new r("hed",-1,1),new r("ethed",0,1),new r("ered",-1,1),new r("e",-1,1),new r("erede",3,1),new r("ende",3,1),new r("erende",5,1),new r("ene",3,1),new r("erne",3,1),new r("ere",3,1),new r("en",-1,1),new r("heden",10,1),new r("eren",10,1),new r("er",-1,1),new r("heder",13,1),new r("erer",13,1),new r("s",-1,2),new r("heds",16,1),new r("es",16,1),new r("endes",18,1),new r("erendes",19,1),new r("enes",18,1),new r("ernes",18,1),new r("eres",18,1),new r("ens",16,1),new r("hedens",24,1),new r("erens",24,1),new r("ers",16,1),new r("ets",16,1),new r("erets",28,1),new r("et",-1,1),new r("eret",30,1)],a=[new r("gd",-1,-1),new r("dt",-1,-1),new r("gt",-1,-1),new r("kt",-1,-1)],d=[new r("ig",-1,1),new r("lig",0,1),new r("elig",1,1),new r("els",-1,1),new r("løst",-1,2)],u=[17,65,16,1,0,0,0,0,0,0,0,0,0,0,0,0,48,0,128],c=[239,254,42,3,0,0,0,0,0,0,0,0,0,0,0,0,16],l=new i;this.setCurrent=function(e){l.setCurrent(e)},this.getCurrent=function(){return l.getCurrent()},this.stem=function(){var r=l.cursor;return function(){var e,r=l.cursor+3;if(t=l.limit,0<=r&&r<=l.limit){for(n=r;;){if(e=l.cursor,l.in_grouping(u,97,248)){l.cursor=e;break}if(l.cursor=e,e>=l.limit)return;l.cursor++}for(;!l.out_grouping(u,97,248);){if(l.cursor>=l.limit)return;l.cursor++}(t=l.cursor)<n&&(t=n)}}(),l.limit_backward=r,l.cursor=l.limit,function(){var e,r;if(l.cursor>=t&&(r=l.limit_backward,l.limit_backward=t,l.ket=l.cursor,e=l.find_among_b(o,32),l.limit_backward=r,e))switch(l.bra=l.cursor,e){case 1:l.slice_del();break;case 2:l.in_grouping_b(c,97,229)&&l.slice_del()}}(),l.cursor=l.limit,e(),l.cursor=l.limit,function(){var r,i,n,s=l.limit-l.cursor;if(l.ket=l.cursor,l.eq_s_b(2,"st")&&(l.bra=l.cursor,l.eq_s_b(2,"ig")&&l.slice_del()),l.cursor=l.limit-s,l.cursor>=t&&(i=l.limit_backward,l.limit_backward=t,l.ket=l.cursor,r=l.find_among_b(d,5),l.limit_backward=i,r))switch(l.bra=l.cursor,r){case 1:l.slice_del(),n=l.limit-l.cursor,e(),l.cursor=l.limit-n;break;case 2:l.slice_from("løs")}}(),l.cursor=l.limit,function(){var e;l.cursor>=t&&(e=l.limit_backward,l.limit_backward=t,l.ket=l.cursor,l.out_grouping_b(u,97,248)?(l.bra=l.cursor,s=l.slice_to(s),l.limit_backward=e,l.eq_v_b(s)&&l.slice_del()):l.limit_backward=e)}(),!0}};return function(e){return"function"==typeof e.update?e.update(function(e){return n.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")}});
|
||||||
1
docs/assets/javascripts/lunr/lunr.de.js
Normal file
1
docs/assets/javascripts/lunr/lunr.de.js
Normal file
File diff suppressed because one or more lines are too long
1
docs/assets/javascripts/lunr/lunr.du.js
Normal file
1
docs/assets/javascripts/lunr/lunr.du.js
Normal file
File diff suppressed because one or more lines are too long
1
docs/assets/javascripts/lunr/lunr.es.js
Normal file
1
docs/assets/javascripts/lunr/lunr.es.js
Normal file
File diff suppressed because one or more lines are too long
1
docs/assets/javascripts/lunr/lunr.fi.js
Normal file
1
docs/assets/javascripts/lunr/lunr.fi.js
Normal file
File diff suppressed because one or more lines are too long
1
docs/assets/javascripts/lunr/lunr.fr.js
Normal file
1
docs/assets/javascripts/lunr/lunr.fr.js
Normal file
File diff suppressed because one or more lines are too long
1
docs/assets/javascripts/lunr/lunr.hu.js
Normal file
1
docs/assets/javascripts/lunr/lunr.hu.js
Normal file
File diff suppressed because one or more lines are too long
1
docs/assets/javascripts/lunr/lunr.it.js
Normal file
1
docs/assets/javascripts/lunr/lunr.it.js
Normal file
File diff suppressed because one or more lines are too long
1
docs/assets/javascripts/lunr/lunr.jp.js
Normal file
1
docs/assets/javascripts/lunr/lunr.jp.js
Normal file
@@ -0,0 +1 @@
|
|||||||
|
!function(e,r){"function"==typeof define&&define.amd?define(r):"object"==typeof exports?module.exports=r():r()(e.lunr)}(this,function(){return function(e){if(void 0===e)throw new Error("Lunr is not present. Please include / require Lunr before this script.");if(void 0===e.stemmerSupport)throw new Error("Lunr stemmer support is not present. Please include / require Lunr stemmer support before this script.");var r="2"==e.version[0];e.jp=function(){this.pipeline.reset(),this.pipeline.add(e.jp.stopWordFilter,e.jp.stemmer),r?this.tokenizer=e.jp.tokenizer:(e.tokenizer&&(e.tokenizer=e.jp.tokenizer),this.tokenizerFn&&(this.tokenizerFn=e.jp.tokenizer))};var t=new e.TinySegmenter;e.jp.tokenizer=function(n){if(!arguments.length||null==n||void 0==n)return[];if(Array.isArray(n))return n.map(function(t){return r?new e.Token(t.toLowerCase()):t.toLowerCase()});for(var i=n.toString().toLowerCase().replace(/^\s+/,""),o=i.length-1;o>=0;o--)if(/\S/.test(i.charAt(o))){i=i.substring(0,o+1);break}return t.segment(i).filter(function(e){return!!e}).map(function(t){return r?new e.Token(t):t})},e.jp.stemmer=function(e){return e},e.Pipeline.registerFunction(e.jp.stemmer,"stemmer-jp"),e.jp.wordCharacters="一二三四五六七八九十百千万億兆一-龠々〆ヵヶぁ-んァ-ヴーア-ン゙a-zA-Za-zA-Z0-90-9",e.jp.stopWordFilter=function(t){if(-1===e.jp.stopWordFilter.stopWords.indexOf(r?t.toString():t))return t},e.jp.stopWordFilter=e.generateStopWordFilter("これ それ あれ この その あの ここ そこ あそこ こちら どこ だれ なに なん 何 私 貴方 貴方方 我々 私達 あの人 あのかた 彼女 彼 です あります おります います は が の に を で え から まで より も どの と し それで しかし".split(" ")),e.Pipeline.registerFunction(e.jp.stopWordFilter,"stopWordFilter-jp")}});
|
||||||
1
docs/assets/javascripts/lunr/lunr.multi.js
Normal file
1
docs/assets/javascripts/lunr/lunr.multi.js
Normal file
@@ -0,0 +1 @@
|
|||||||
|
!function(e,i){"function"==typeof define&&define.amd?define(i):"object"==typeof exports?module.exports=i():i()(e.lunr)}(this,function(){return function(e){e.multiLanguage=function(){for(var i=Array.prototype.slice.call(arguments),t=i.join("-"),r="",n=[],s=[],p=0;p<i.length;++p)"en"==i[p]?(r+="\\w",n.unshift(e.stopWordFilter),n.push(e.stemmer),s.push(e.stemmer)):(r+=e[i[p]].wordCharacters,n.unshift(e[i[p]].stopWordFilter),n.push(e[i[p]].stemmer),s.push(e[i[p]].stemmer));var o=e.trimmerSupport.generateTrimmer(r);return e.Pipeline.registerFunction(o,"lunr-multi-trimmer-"+t),n.unshift(o),function(){this.pipeline.reset(),this.pipeline.add.apply(this.pipeline,n),this.searchPipeline&&(this.searchPipeline.reset(),this.searchPipeline.add.apply(this.searchPipeline,s))}}}});
|
||||||
1
docs/assets/javascripts/lunr/lunr.no.js
Normal file
1
docs/assets/javascripts/lunr/lunr.no.js
Normal file
@@ -0,0 +1 @@
|
|||||||
|
!function(e,r){"function"==typeof define&&define.amd?define(r):"object"==typeof exports?module.exports=r():r()(e.lunr)}(this,function(){return function(e){if(void 0===e)throw new Error("Lunr is not present. Please include / require Lunr before this script.");if(void 0===e.stemmerSupport)throw new Error("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(){var r=e.stemmerSupport.Among,n=e.stemmerSupport.SnowballProgram,i=new function(){var e,i,t=[new r("a",-1,1),new r("e",-1,1),new r("ede",1,1),new r("ande",1,1),new r("ende",1,1),new r("ane",1,1),new r("ene",1,1),new r("hetene",6,1),new r("erte",1,3),new r("en",-1,1),new r("heten",9,1),new r("ar",-1,1),new r("er",-1,1),new r("heter",12,1),new r("s",-1,2),new r("as",14,1),new r("es",14,1),new r("edes",16,1),new r("endes",16,1),new r("enes",16,1),new r("hetenes",19,1),new r("ens",14,1),new r("hetens",21,1),new r("ers",14,1),new r("ets",14,1),new r("et",-1,1),new r("het",25,1),new r("ert",-1,3),new r("ast",-1,1)],o=[new r("dt",-1,-1),new r("vt",-1,-1)],s=[new r("leg",-1,1),new r("eleg",0,1),new r("ig",-1,1),new r("eig",2,1),new r("lig",2,1),new r("elig",4,1),new r("els",-1,1),new r("lov",-1,1),new r("elov",7,1),new r("slov",7,1),new r("hetslov",9,1)],a=[17,65,16,1,0,0,0,0,0,0,0,0,0,0,0,0,48,0,128],m=[119,125,149,1],u=new n;this.setCurrent=function(e){u.setCurrent(e)},this.getCurrent=function(){return u.getCurrent()},this.stem=function(){var r=u.cursor;return function(){var r,n=u.cursor+3;if(i=u.limit,0<=n||n<=u.limit){for(e=n;;){if(r=u.cursor,u.in_grouping(a,97,248)){u.cursor=r;break}if(r>=u.limit)return;u.cursor=r+1}for(;!u.out_grouping(a,97,248);){if(u.cursor>=u.limit)return;u.cursor++}(i=u.cursor)<e&&(i=e)}}(),u.limit_backward=r,u.cursor=u.limit,function(){var e,r,n;if(u.cursor>=i&&(r=u.limit_backward,u.limit_backward=i,u.ket=u.cursor,e=u.find_among_b(t,29),u.limit_backward=r,e))switch(u.bra=u.cursor,e){case 1:u.slice_del();break;case 2:n=u.limit-u.cursor,u.in_grouping_b(m,98,122)?u.slice_del():(u.cursor=u.limit-n,u.eq_s_b(1,"k")&&u.out_grouping_b(a,97,248)&&u.slice_del());break;case 3:u.slice_from("er")}}(),u.cursor=u.limit,function(){var e,r=u.limit-u.cursor;u.cursor>=i&&(e=u.limit_backward,u.limit_backward=i,u.ket=u.cursor,u.find_among_b(o,2)?(u.bra=u.cursor,u.limit_backward=e,u.cursor=u.limit-r,u.cursor>u.limit_backward&&(u.cursor--,u.bra=u.cursor,u.slice_del())):u.limit_backward=e)}(),u.cursor=u.limit,function(){var e,r;u.cursor>=i&&(r=u.limit_backward,u.limit_backward=i,u.ket=u.cursor,(e=u.find_among_b(s,11))?(u.bra=u.cursor,u.limit_backward=r,1==e&&u.slice_del()):u.limit_backward=r)}(),!0}};return function(e){return"function"==typeof e.update?e.update(function(e){return i.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")}});
|
||||||
1
docs/assets/javascripts/lunr/lunr.pt.js
Normal file
1
docs/assets/javascripts/lunr/lunr.pt.js
Normal file
File diff suppressed because one or more lines are too long
1
docs/assets/javascripts/lunr/lunr.ro.js
Normal file
1
docs/assets/javascripts/lunr/lunr.ro.js
Normal file
File diff suppressed because one or more lines are too long
1
docs/assets/javascripts/lunr/lunr.ru.js
Normal file
1
docs/assets/javascripts/lunr/lunr.ru.js
Normal file
File diff suppressed because one or more lines are too long
1
docs/assets/javascripts/lunr/lunr.stemmer.support.js
Normal file
1
docs/assets/javascripts/lunr/lunr.stemmer.support.js
Normal file
@@ -0,0 +1 @@
|
|||||||
|
!function(r,t){"function"==typeof define&&define.amd?define(t):"object"==typeof exports?module.exports=t():t()(r.lunr)}(this,function(){return function(r){r.stemmerSupport={Among:function(r,t,i,s){if(this.toCharArray=function(r){for(var t=r.length,i=new Array(t),s=0;s<t;s++)i[s]=r.charCodeAt(s);return i},!r&&""!=r||!t&&0!=t||!i)throw"Bad Among initialisation: s:"+r+", substring_i: "+t+", result: "+i;this.s_size=r.length,this.s=this.toCharArray(r),this.substring_i=t,this.result=i,this.method=s},SnowballProgram:function(){var r;return{bra:0,ket:0,limit:0,cursor:0,limit_backward:0,setCurrent:function(t){r=t,this.cursor=0,this.limit=t.length,this.limit_backward=0,this.bra=this.cursor,this.ket=this.limit},getCurrent:function(){var t=r;return r=null,t},in_grouping:function(t,i,s){if(this.cursor<this.limit){var e=r.charCodeAt(this.cursor);if(e<=s&&e>=i&&(e-=i,t[e>>3]&1<<(7&e)))return this.cursor++,!0}return!1},in_grouping_b:function(t,i,s){if(this.cursor>this.limit_backward){var e=r.charCodeAt(this.cursor-1);if(e<=s&&e>=i&&(e-=i,t[e>>3]&1<<(7&e)))return this.cursor--,!0}return!1},out_grouping:function(t,i,s){if(this.cursor<this.limit){var e=r.charCodeAt(this.cursor);if(e>s||e<i)return this.cursor++,!0;if(e-=i,!(t[e>>3]&1<<(7&e)))return this.cursor++,!0}return!1},out_grouping_b:function(t,i,s){if(this.cursor>this.limit_backward){var e=r.charCodeAt(this.cursor-1);if(e>s||e<i)return this.cursor--,!0;if(e-=i,!(t[e>>3]&1<<(7&e)))return this.cursor--,!0}return!1},eq_s:function(t,i){if(this.limit-this.cursor<t)return!1;for(var s=0;s<t;s++)if(r.charCodeAt(this.cursor+s)!=i.charCodeAt(s))return!1;return this.cursor+=t,!0},eq_s_b:function(t,i){if(this.cursor-this.limit_backward<t)return!1;for(var s=0;s<t;s++)if(r.charCodeAt(this.cursor-t+s)!=i.charCodeAt(s))return!1;return this.cursor-=t,!0},find_among:function(t,i){for(var s=0,e=i,n=this.cursor,u=this.limit,o=0,h=0,c=!1;;){for(var a=s+(e-s>>1),f=0,l=o<h?o:h,_=t[a],m=l;m<_.s_size;m++){if(n+l==u){f=-1;break}if(f=r.charCodeAt(n+l)-_.s[m])break;l++}if(f<0?(e=a,h=l):(s=a,o=l),e-s<=1){if(s>0||e==s||c)break;c=!0}}for(;;){if(o>=(_=t[s]).s_size){if(this.cursor=n+_.s_size,!_.method)return _.result;var b=_.method();if(this.cursor=n+_.s_size,b)return _.result}if((s=_.substring_i)<0)return 0}},find_among_b:function(t,i){for(var s=0,e=i,n=this.cursor,u=this.limit_backward,o=0,h=0,c=!1;;){for(var a=s+(e-s>>1),f=0,l=o<h?o:h,_=(m=t[a]).s_size-1-l;_>=0;_--){if(n-l==u){f=-1;break}if(f=r.charCodeAt(n-1-l)-m.s[_])break;l++}if(f<0?(e=a,h=l):(s=a,o=l),e-s<=1){if(s>0||e==s||c)break;c=!0}}for(;;){var m=t[s];if(o>=m.s_size){if(this.cursor=n-m.s_size,!m.method)return m.result;var b=m.method();if(this.cursor=n-m.s_size,b)return m.result}if((s=m.substring_i)<0)return 0}},replace_s:function(t,i,s){var e=s.length-(i-t),n=r.substring(0,t),u=r.substring(i);return r=n+s+u,this.limit+=e,this.cursor>=i?this.cursor+=e:this.cursor>t&&(this.cursor=t),e},slice_check:function(){if(this.bra<0||this.bra>this.ket||this.ket>this.limit||this.limit>r.length)throw"faulty slice operation"},slice_from:function(r){this.slice_check(),this.replace_s(this.bra,this.ket,r)},slice_del:function(){this.slice_from("")},insert:function(r,t,i){var s=this.replace_s(r,t,i);r<=this.bra&&(this.bra+=s),r<=this.ket&&(this.ket+=s)},slice_to:function(){return this.slice_check(),r.substring(this.bra,this.ket)},eq_v_b:function(r){return this.eq_s_b(r.length,r)}}}},r.trimmerSupport={generateTrimmer:function(r){var t=new RegExp("^[^"+r+"]+"),i=new RegExp("[^"+r+"]+$");return function(r){return"function"==typeof r.update?r.update(function(r){return r.replace(t,"").replace(i,"")}):r.replace(t,"").replace(i,"")}}}}});
|
||||||
1
docs/assets/javascripts/lunr/lunr.sv.js
Normal file
1
docs/assets/javascripts/lunr/lunr.sv.js
Normal file
@@ -0,0 +1 @@
|
|||||||
|
!function(e,r){"function"==typeof define&&define.amd?define(r):"object"==typeof exports?module.exports=r():r()(e.lunr)}(this,function(){return function(e){if(void 0===e)throw new Error("Lunr is not present. Please include / require Lunr before this script.");if(void 0===e.stemmerSupport)throw new Error("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(){var r=e.stemmerSupport.Among,n=e.stemmerSupport.SnowballProgram,t=new function(){var e,t,i=[new r("a",-1,1),new r("arna",0,1),new r("erna",0,1),new r("heterna",2,1),new r("orna",0,1),new r("ad",-1,1),new r("e",-1,1),new r("ade",6,1),new r("ande",6,1),new r("arne",6,1),new r("are",6,1),new r("aste",6,1),new r("en",-1,1),new r("anden",12,1),new r("aren",12,1),new r("heten",12,1),new r("ern",-1,1),new r("ar",-1,1),new r("er",-1,1),new r("heter",18,1),new r("or",-1,1),new r("s",-1,2),new r("as",21,1),new r("arnas",22,1),new r("ernas",22,1),new r("ornas",22,1),new r("es",21,1),new r("ades",26,1),new r("andes",26,1),new r("ens",21,1),new r("arens",29,1),new r("hetens",29,1),new r("erns",21,1),new r("at",-1,1),new r("andet",-1,1),new r("het",-1,1),new r("ast",-1,1)],s=[new r("dd",-1,-1),new r("gd",-1,-1),new r("nn",-1,-1),new r("dt",-1,-1),new r("gt",-1,-1),new r("kt",-1,-1),new r("tt",-1,-1)],a=[new r("ig",-1,1),new r("lig",0,1),new r("els",-1,1),new r("fullt",-1,3),new r("löst",-1,2)],o=[17,65,16,1,0,0,0,0,0,0,0,0,0,0,0,0,24,0,32],u=[119,127,149],c=new n;this.setCurrent=function(e){c.setCurrent(e)},this.getCurrent=function(){return c.getCurrent()},this.stem=function(){var r=c.cursor;return function(){var r,n=c.cursor+3;if(t=c.limit,0<=n||n<=c.limit){for(e=n;;){if(r=c.cursor,c.in_grouping(o,97,246)){c.cursor=r;break}if(c.cursor=r,c.cursor>=c.limit)return;c.cursor++}for(;!c.out_grouping(o,97,246);){if(c.cursor>=c.limit)return;c.cursor++}(t=c.cursor)<e&&(t=e)}}(),c.limit_backward=r,c.cursor=c.limit,function(){var e,r=c.limit_backward;if(c.cursor>=t&&(c.limit_backward=t,c.cursor=c.limit,c.ket=c.cursor,e=c.find_among_b(i,37),c.limit_backward=r,e))switch(c.bra=c.cursor,e){case 1:c.slice_del();break;case 2:c.in_grouping_b(u,98,121)&&c.slice_del()}}(),c.cursor=c.limit,function(){var e=c.limit_backward;c.cursor>=t&&(c.limit_backward=t,c.cursor=c.limit,c.find_among_b(s,7)&&(c.cursor=c.limit,c.ket=c.cursor,c.cursor>c.limit_backward&&(c.bra=--c.cursor,c.slice_del())),c.limit_backward=e)}(),c.cursor=c.limit,function(){var e,r;if(c.cursor>=t){if(r=c.limit_backward,c.limit_backward=t,c.cursor=c.limit,c.ket=c.cursor,e=c.find_among_b(a,5))switch(c.bra=c.cursor,e){case 1:c.slice_del();break;case 2:c.slice_from("lös");break;case 3:c.slice_from("full")}c.limit_backward=r}}(),!0}};return function(e){return"function"==typeof e.update?e.update(function(e){return t.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")}});
|
||||||
1
docs/assets/javascripts/lunr/lunr.tr.js
Normal file
1
docs/assets/javascripts/lunr/lunr.tr.js
Normal file
File diff suppressed because one or more lines are too long
1
docs/assets/javascripts/lunr/tinyseg.js
Normal file
1
docs/assets/javascripts/lunr/tinyseg.js
Normal file
File diff suppressed because one or more lines are too long
1
docs/assets/javascripts/modernizr.1aa3b519.js
Normal file
1
docs/assets/javascripts/modernizr.1aa3b519.js
Normal file
File diff suppressed because one or more lines are too long
2
docs/assets/stylesheets/application-palette.792431c1.css
Normal file
2
docs/assets/stylesheets/application-palette.792431c1.css
Normal file
File diff suppressed because one or more lines are too long
2
docs/assets/stylesheets/application.bcabdff3.css
Normal file
2
docs/assets/stylesheets/application.bcabdff3.css
Normal file
File diff suppressed because one or more lines are too long
495
docs/convert/index.html
Normal file
495
docs/convert/index.html
Normal file
@@ -0,0 +1,495 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en" class="no-js">
|
||||||
|
<head>
|
||||||
|
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||||
|
<meta http-equiv="x-ua-compatible" content="ie=edge">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<meta name="lang:clipboard.copy" content="Copy to clipboard">
|
||||||
|
|
||||||
|
<meta name="lang:clipboard.copied" content="Copied to clipboard">
|
||||||
|
|
||||||
|
<meta name="lang:search.language" content="en">
|
||||||
|
|
||||||
|
<meta name="lang:search.result.none" content="No matching documents">
|
||||||
|
|
||||||
|
<meta name="lang:search.result.one" content="1 matching document">
|
||||||
|
|
||||||
|
<meta name="lang:search.result.other" content="# matching documents">
|
||||||
|
|
||||||
|
<meta name="lang:search.tokenizer" content="[\s\-]+">
|
||||||
|
|
||||||
|
<link rel="shortcut icon" href="../assets/images/favicon.png">
|
||||||
|
<meta name="generator" content="mkdocs-0.17.2, mkdocs-material-2.2.5">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<title>Convert - Yq</title>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<link rel="stylesheet" href="../assets/stylesheets/application.bcabdff3.css">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<script src="../assets/javascripts/modernizr.1aa3b519.js"></script>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,400i,700|Roboto+Mono">
|
||||||
|
<style>body,input{font-family:"Roboto","Helvetica Neue",Helvetica,Arial,sans-serif}code,kbd,pre{font-family:"Roboto Mono","Courier New",Courier,monospace}</style>
|
||||||
|
|
||||||
|
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<svg class="md-svg">
|
||||||
|
<defs>
|
||||||
|
|
||||||
|
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="416" height="448" viewBox="0 0 416 448" id="github"><path fill="currentColor" d="M160 304q0 10-3.125 20.5t-10.75 19T128 352t-18.125-8.5-10.75-19T96 304t3.125-20.5 10.75-19T128 256t18.125 8.5 10.75 19T160 304zm160 0q0 10-3.125 20.5t-10.75 19T288 352t-18.125-8.5-10.75-19T256 304t3.125-20.5 10.75-19T288 256t18.125 8.5 10.75 19T320 304zm40 0q0-30-17.25-51T296 232q-10.25 0-48.75 5.25Q229.5 240 208 240t-39.25-2.75Q130.75 232 120 232q-29.5 0-46.75 21T56 304q0 22 8 38.375t20.25 25.75 30.5 15 35 7.375 37.25 1.75h42q20.5 0 37.25-1.75t35-7.375 30.5-15 20.25-25.75T360 304zm56-44q0 51.75-15.25 82.75-9.5 19.25-26.375 33.25t-35.25 21.5-42.5 11.875-42.875 5.5T212 416q-19.5 0-35.5-.75t-36.875-3.125-38.125-7.5-34.25-12.875T37 371.5t-21.5-28.75Q0 312 0 260q0-59.25 34-99-6.75-20.5-6.75-42.5 0-29 12.75-54.5 27 0 47.5 9.875t47.25 30.875Q171.5 96 212 96q37 0 70 8 26.25-20.5 46.75-30.25T376 64q12.75 25.5 12.75 54.5 0 21.75-6.75 42 34 40 34 99.5z"/></svg>
|
||||||
|
|
||||||
|
</defs>
|
||||||
|
</svg>
|
||||||
|
<input class="md-toggle" data-md-toggle="drawer" type="checkbox" id="drawer">
|
||||||
|
<input class="md-toggle" data-md-toggle="search" type="checkbox" id="search">
|
||||||
|
<label class="md-overlay" data-md-component="overlay" for="drawer"></label>
|
||||||
|
|
||||||
|
<header class="md-header" data-md-component="header">
|
||||||
|
<nav class="md-header-nav md-grid">
|
||||||
|
<div class="md-flex">
|
||||||
|
<div class="md-flex__cell md-flex__cell--shrink">
|
||||||
|
<a href=".." title="Yq" class="md-header-nav__button md-logo">
|
||||||
|
|
||||||
|
<i class="md-icon"></i>
|
||||||
|
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<div class="md-flex__cell md-flex__cell--shrink">
|
||||||
|
<label class="md-icon md-icon--menu md-header-nav__button" for="drawer"></label>
|
||||||
|
</div>
|
||||||
|
<div class="md-flex__cell md-flex__cell--stretch">
|
||||||
|
<div class="md-flex__ellipsis md-header-nav__title" data-md-component="title">
|
||||||
|
|
||||||
|
|
||||||
|
<span class="md-header-nav__topic">
|
||||||
|
Yq
|
||||||
|
</span>
|
||||||
|
<span class="md-header-nav__topic">
|
||||||
|
Convert
|
||||||
|
</span>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="md-flex__cell md-flex__cell--shrink">
|
||||||
|
|
||||||
|
|
||||||
|
<label class="md-icon md-icon--search md-header-nav__button" for="search"></label>
|
||||||
|
|
||||||
|
<div class="md-search" data-md-component="search" role="dialog">
|
||||||
|
<label class="md-search__overlay" for="search"></label>
|
||||||
|
<div class="md-search__inner">
|
||||||
|
<form class="md-search__form" name="search">
|
||||||
|
<input type="text" class="md-search__input" name="query" required placeholder="Search" autocapitalize="off" autocorrect="off" autocomplete="off" spellcheck="false" data-md-component="query">
|
||||||
|
<label class="md-icon md-search__icon" for="search"></label>
|
||||||
|
<button type="reset" class="md-icon md-search__icon" data-md-component="reset"></button>
|
||||||
|
</form>
|
||||||
|
<div class="md-search__output">
|
||||||
|
<div class="md-search__scrollwrap" data-md-scrollfix>
|
||||||
|
<div class="md-search-result" data-md-component="result">
|
||||||
|
<div class="md-search-result__meta">
|
||||||
|
Type to start searching
|
||||||
|
</div>
|
||||||
|
<ol class="md-search-result__list"></ol>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="md-flex__cell md-flex__cell--shrink">
|
||||||
|
<div class="md-header-nav__source">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<a href="https://github.com/mikefarah/yq/" title="Go to repository" class="md-source" data-md-source="github">
|
||||||
|
|
||||||
|
<div class="md-source__icon">
|
||||||
|
<svg viewBox="0 0 24 24" width="24" height="24">
|
||||||
|
<use xlink:href="#github" width="24" height="24"></use>
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="md-source__repository">
|
||||||
|
mikefarah/yq
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<div class="md-container">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<main class="md-main">
|
||||||
|
<div class="md-main__inner md-grid" data-md-component="container">
|
||||||
|
|
||||||
|
|
||||||
|
<div class="md-sidebar md-sidebar--primary" data-md-component="navigation">
|
||||||
|
<div class="md-sidebar__scrollwrap">
|
||||||
|
<div class="md-sidebar__inner">
|
||||||
|
<nav class="md-nav md-nav--primary" data-md-level="0">
|
||||||
|
<label class="md-nav__title md-nav__title--site" for="drawer">
|
||||||
|
<span class="md-nav__button md-logo">
|
||||||
|
|
||||||
|
<i class="md-icon"></i>
|
||||||
|
|
||||||
|
</span>
|
||||||
|
Yq
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<div class="md-nav__source">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<a href="https://github.com/mikefarah/yq/" title="Go to repository" class="md-source" data-md-source="github">
|
||||||
|
|
||||||
|
<div class="md-source__icon">
|
||||||
|
<svg viewBox="0 0 24 24" width="24" height="24">
|
||||||
|
<use xlink:href="#github" width="24" height="24"></use>
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="md-source__repository">
|
||||||
|
mikefarah/yq
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<ul class="md-nav__list" data-md-scrollfix>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href=".." title="Install" class="md-nav__link">
|
||||||
|
Install
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="../read/" title="Read" class="md-nav__link">
|
||||||
|
Read
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="../write/" title="Write/Update" class="md-nav__link">
|
||||||
|
Write/Update
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="../delete/" title="Delete" class="md-nav__link">
|
||||||
|
Delete
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="../create/" title="Create" class="md-nav__link">
|
||||||
|
Create
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<li class="md-nav__item md-nav__item--active">
|
||||||
|
|
||||||
|
<input class="md-toggle md-nav__toggle" data-md-toggle="toc" type="checkbox" id="toc">
|
||||||
|
|
||||||
|
|
||||||
|
<label class="md-nav__link md-nav__link--active" for="toc">
|
||||||
|
Convert
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<a href="./" title="Convert" class="md-nav__link md-nav__link--active">
|
||||||
|
Convert
|
||||||
|
</a>
|
||||||
|
|
||||||
|
|
||||||
|
<nav class="md-nav md-nav--secondary">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<label class="md-nav__title" for="toc">Table of contents</label>
|
||||||
|
<ul class="md-nav__list" data-md-scrollfix>
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="#yaml-to-json" title="Yaml to Json" class="md-nav__link">
|
||||||
|
Yaml to Json
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="#json-to-yaml" title="Json to Yaml" class="md-nav__link">
|
||||||
|
Json to Yaml
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="../merge/" title="Merge" class="md-nav__link">
|
||||||
|
Merge
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
|
||||||
|
</ul>
|
||||||
|
</nav>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="md-sidebar md-sidebar--secondary" data-md-component="toc">
|
||||||
|
<div class="md-sidebar__scrollwrap">
|
||||||
|
<div class="md-sidebar__inner">
|
||||||
|
|
||||||
|
<nav class="md-nav md-nav--secondary">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<label class="md-nav__title" for="toc">Table of contents</label>
|
||||||
|
<ul class="md-nav__list" data-md-scrollfix>
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="#yaml-to-json" title="Yaml to Json" class="md-nav__link">
|
||||||
|
Yaml to Json
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="#json-to-yaml" title="Json to Yaml" class="md-nav__link">
|
||||||
|
Json to Yaml
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
</nav>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="md-content">
|
||||||
|
<article class="md-content__inner md-typeset">
|
||||||
|
|
||||||
|
|
||||||
|
<a href="https://github.com/mikefarah/yq/edit/master/docs/convert.md" title="Edit this page" class="md-icon md-content__icon"></a>
|
||||||
|
|
||||||
|
|
||||||
|
<h1>Convert</h1>
|
||||||
|
|
||||||
|
<h3 id="yaml-to-json">Yaml to Json<a class="headerlink" href="#yaml-to-json" title="Permanent link">¶</a></h3>
|
||||||
|
<p>To convert output to json, use the --tojson (or -j) flag. This can only be used with the read command.</p>
|
||||||
|
<p>Given a sample.yaml file of:</p>
|
||||||
|
<pre><code class="yaml">b:
|
||||||
|
c: 2
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<p>then</p>
|
||||||
|
<pre><code class="bash">yq r -j sample.yaml b.c
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<p>will output</p>
|
||||||
|
<pre><code class="json">{"b":{"c":2}}
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<h3 id="json-to-yaml">Json to Yaml<a class="headerlink" href="#json-to-yaml" title="Permanent link">¶</a></h3>
|
||||||
|
<p>To read in json, just pass in a json file instead of yaml, it will just work :)</p>
|
||||||
|
<p>e.g given a json file</p>
|
||||||
|
<pre><code class="json">{"a":"Easy! as one two three","b":{"c":2,"d":[3,4]}}
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<p>then</p>
|
||||||
|
<pre><code class="bash">yq r sample.json
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<p>will output</p>
|
||||||
|
<pre><code class="yaml">a: Easy! as one two three
|
||||||
|
b:
|
||||||
|
c: 2
|
||||||
|
d:
|
||||||
|
- 3
|
||||||
|
- 4
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</article>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
|
||||||
|
|
||||||
|
<footer class="md-footer">
|
||||||
|
|
||||||
|
<div class="md-footer-nav">
|
||||||
|
<nav class="md-footer-nav__inner md-grid">
|
||||||
|
|
||||||
|
<a href="../create/" title="Create" class="md-flex md-footer-nav__link md-footer-nav__link--prev" rel="prev">
|
||||||
|
<div class="md-flex__cell md-flex__cell--shrink">
|
||||||
|
<i class="md-icon md-icon--arrow-back md-footer-nav__button"></i>
|
||||||
|
</div>
|
||||||
|
<div class="md-flex__cell md-flex__cell--stretch md-footer-nav__title">
|
||||||
|
<span class="md-flex__ellipsis">
|
||||||
|
<span class="md-footer-nav__direction">
|
||||||
|
Previous
|
||||||
|
</span>
|
||||||
|
Create
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
|
||||||
|
<a href="../merge/" title="Merge" class="md-flex md-footer-nav__link md-footer-nav__link--next" rel="next">
|
||||||
|
<div class="md-flex__cell md-flex__cell--stretch md-footer-nav__title">
|
||||||
|
<span class="md-flex__ellipsis">
|
||||||
|
<span class="md-footer-nav__direction">
|
||||||
|
Next
|
||||||
|
</span>
|
||||||
|
Merge
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div class="md-flex__cell md-flex__cell--shrink">
|
||||||
|
<i class="md-icon md-icon--arrow-forward md-footer-nav__button"></i>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</nav>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="md-footer-meta md-typeset">
|
||||||
|
<div class="md-footer-meta__inner md-grid">
|
||||||
|
<div class="md-footer-copyright">
|
||||||
|
|
||||||
|
powered by
|
||||||
|
<a href="http://www.mkdocs.org">MkDocs</a>
|
||||||
|
and
|
||||||
|
<a href="https://squidfunk.github.io/mkdocs-material/">
|
||||||
|
Material for MkDocs</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="md-footer-social">
|
||||||
|
|
||||||
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
|
||||||
|
|
||||||
|
<a href="https://github.com/mikefarah" class="md-footer-social__link fa fa-github"></a>
|
||||||
|
|
||||||
|
<a href="https://www.linkedin.com/in/mike-farah-b5a75b2/" class="md-footer-social__link fa fa-linkedin"></a>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</footer>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script src="../assets/javascripts/application.6cdc17f0.js"></script>
|
||||||
|
|
||||||
|
<script>app.initialize({version:"0.17.2",url:{base:".."}})</script>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
525
docs/create/index.html
Normal file
525
docs/create/index.html
Normal file
@@ -0,0 +1,525 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en" class="no-js">
|
||||||
|
<head>
|
||||||
|
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||||
|
<meta http-equiv="x-ua-compatible" content="ie=edge">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<meta name="lang:clipboard.copy" content="Copy to clipboard">
|
||||||
|
|
||||||
|
<meta name="lang:clipboard.copied" content="Copied to clipboard">
|
||||||
|
|
||||||
|
<meta name="lang:search.language" content="en">
|
||||||
|
|
||||||
|
<meta name="lang:search.result.none" content="No matching documents">
|
||||||
|
|
||||||
|
<meta name="lang:search.result.one" content="1 matching document">
|
||||||
|
|
||||||
|
<meta name="lang:search.result.other" content="# matching documents">
|
||||||
|
|
||||||
|
<meta name="lang:search.tokenizer" content="[\s\-]+">
|
||||||
|
|
||||||
|
<link rel="shortcut icon" href="../assets/images/favicon.png">
|
||||||
|
<meta name="generator" content="mkdocs-0.17.2, mkdocs-material-2.2.5">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<title>Create - Yq</title>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<link rel="stylesheet" href="../assets/stylesheets/application.bcabdff3.css">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<script src="../assets/javascripts/modernizr.1aa3b519.js"></script>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,400i,700|Roboto+Mono">
|
||||||
|
<style>body,input{font-family:"Roboto","Helvetica Neue",Helvetica,Arial,sans-serif}code,kbd,pre{font-family:"Roboto Mono","Courier New",Courier,monospace}</style>
|
||||||
|
|
||||||
|
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<svg class="md-svg">
|
||||||
|
<defs>
|
||||||
|
|
||||||
|
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="416" height="448" viewBox="0 0 416 448" id="github"><path fill="currentColor" d="M160 304q0 10-3.125 20.5t-10.75 19T128 352t-18.125-8.5-10.75-19T96 304t3.125-20.5 10.75-19T128 256t18.125 8.5 10.75 19T160 304zm160 0q0 10-3.125 20.5t-10.75 19T288 352t-18.125-8.5-10.75-19T256 304t3.125-20.5 10.75-19T288 256t18.125 8.5 10.75 19T320 304zm40 0q0-30-17.25-51T296 232q-10.25 0-48.75 5.25Q229.5 240 208 240t-39.25-2.75Q130.75 232 120 232q-29.5 0-46.75 21T56 304q0 22 8 38.375t20.25 25.75 30.5 15 35 7.375 37.25 1.75h42q20.5 0 37.25-1.75t35-7.375 30.5-15 20.25-25.75T360 304zm56-44q0 51.75-15.25 82.75-9.5 19.25-26.375 33.25t-35.25 21.5-42.5 11.875-42.875 5.5T212 416q-19.5 0-35.5-.75t-36.875-3.125-38.125-7.5-34.25-12.875T37 371.5t-21.5-28.75Q0 312 0 260q0-59.25 34-99-6.75-20.5-6.75-42.5 0-29 12.75-54.5 27 0 47.5 9.875t47.25 30.875Q171.5 96 212 96q37 0 70 8 26.25-20.5 46.75-30.25T376 64q12.75 25.5 12.75 54.5 0 21.75-6.75 42 34 40 34 99.5z"/></svg>
|
||||||
|
|
||||||
|
</defs>
|
||||||
|
</svg>
|
||||||
|
<input class="md-toggle" data-md-toggle="drawer" type="checkbox" id="drawer">
|
||||||
|
<input class="md-toggle" data-md-toggle="search" type="checkbox" id="search">
|
||||||
|
<label class="md-overlay" data-md-component="overlay" for="drawer"></label>
|
||||||
|
|
||||||
|
<header class="md-header" data-md-component="header">
|
||||||
|
<nav class="md-header-nav md-grid">
|
||||||
|
<div class="md-flex">
|
||||||
|
<div class="md-flex__cell md-flex__cell--shrink">
|
||||||
|
<a href=".." title="Yq" class="md-header-nav__button md-logo">
|
||||||
|
|
||||||
|
<i class="md-icon"></i>
|
||||||
|
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<div class="md-flex__cell md-flex__cell--shrink">
|
||||||
|
<label class="md-icon md-icon--menu md-header-nav__button" for="drawer"></label>
|
||||||
|
</div>
|
||||||
|
<div class="md-flex__cell md-flex__cell--stretch">
|
||||||
|
<div class="md-flex__ellipsis md-header-nav__title" data-md-component="title">
|
||||||
|
|
||||||
|
|
||||||
|
<span class="md-header-nav__topic">
|
||||||
|
Yq
|
||||||
|
</span>
|
||||||
|
<span class="md-header-nav__topic">
|
||||||
|
Create
|
||||||
|
</span>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="md-flex__cell md-flex__cell--shrink">
|
||||||
|
|
||||||
|
|
||||||
|
<label class="md-icon md-icon--search md-header-nav__button" for="search"></label>
|
||||||
|
|
||||||
|
<div class="md-search" data-md-component="search" role="dialog">
|
||||||
|
<label class="md-search__overlay" for="search"></label>
|
||||||
|
<div class="md-search__inner">
|
||||||
|
<form class="md-search__form" name="search">
|
||||||
|
<input type="text" class="md-search__input" name="query" required placeholder="Search" autocapitalize="off" autocorrect="off" autocomplete="off" spellcheck="false" data-md-component="query">
|
||||||
|
<label class="md-icon md-search__icon" for="search"></label>
|
||||||
|
<button type="reset" class="md-icon md-search__icon" data-md-component="reset"></button>
|
||||||
|
</form>
|
||||||
|
<div class="md-search__output">
|
||||||
|
<div class="md-search__scrollwrap" data-md-scrollfix>
|
||||||
|
<div class="md-search-result" data-md-component="result">
|
||||||
|
<div class="md-search-result__meta">
|
||||||
|
Type to start searching
|
||||||
|
</div>
|
||||||
|
<ol class="md-search-result__list"></ol>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="md-flex__cell md-flex__cell--shrink">
|
||||||
|
<div class="md-header-nav__source">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<a href="https://github.com/mikefarah/yq/" title="Go to repository" class="md-source" data-md-source="github">
|
||||||
|
|
||||||
|
<div class="md-source__icon">
|
||||||
|
<svg viewBox="0 0 24 24" width="24" height="24">
|
||||||
|
<use xlink:href="#github" width="24" height="24"></use>
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="md-source__repository">
|
||||||
|
mikefarah/yq
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<div class="md-container">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<main class="md-main">
|
||||||
|
<div class="md-main__inner md-grid" data-md-component="container">
|
||||||
|
|
||||||
|
|
||||||
|
<div class="md-sidebar md-sidebar--primary" data-md-component="navigation">
|
||||||
|
<div class="md-sidebar__scrollwrap">
|
||||||
|
<div class="md-sidebar__inner">
|
||||||
|
<nav class="md-nav md-nav--primary" data-md-level="0">
|
||||||
|
<label class="md-nav__title md-nav__title--site" for="drawer">
|
||||||
|
<span class="md-nav__button md-logo">
|
||||||
|
|
||||||
|
<i class="md-icon"></i>
|
||||||
|
|
||||||
|
</span>
|
||||||
|
Yq
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<div class="md-nav__source">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<a href="https://github.com/mikefarah/yq/" title="Go to repository" class="md-source" data-md-source="github">
|
||||||
|
|
||||||
|
<div class="md-source__icon">
|
||||||
|
<svg viewBox="0 0 24 24" width="24" height="24">
|
||||||
|
<use xlink:href="#github" width="24" height="24"></use>
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="md-source__repository">
|
||||||
|
mikefarah/yq
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<ul class="md-nav__list" data-md-scrollfix>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href=".." title="Install" class="md-nav__link">
|
||||||
|
Install
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="../read/" title="Read" class="md-nav__link">
|
||||||
|
Read
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="../write/" title="Write/Update" class="md-nav__link">
|
||||||
|
Write/Update
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="../delete/" title="Delete" class="md-nav__link">
|
||||||
|
Delete
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<li class="md-nav__item md-nav__item--active">
|
||||||
|
|
||||||
|
<input class="md-toggle md-nav__toggle" data-md-toggle="toc" type="checkbox" id="toc">
|
||||||
|
|
||||||
|
|
||||||
|
<label class="md-nav__link md-nav__link--active" for="toc">
|
||||||
|
Create
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<a href="./" title="Create" class="md-nav__link md-nav__link--active">
|
||||||
|
Create
|
||||||
|
</a>
|
||||||
|
|
||||||
|
|
||||||
|
<nav class="md-nav md-nav--secondary">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<label class="md-nav__title" for="toc">Table of contents</label>
|
||||||
|
<ul class="md-nav__list" data-md-scrollfix>
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="#creating-a-simple-yaml-file" title="Creating a simple yaml file" class="md-nav__link">
|
||||||
|
Creating a simple yaml file
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="#creating-using-a-create-script" title="Creating using a create script" class="md-nav__link">
|
||||||
|
Creating using a create script
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="#keys-with-dots" title="Keys with dots" class="md-nav__link">
|
||||||
|
Keys with dots
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="../convert/" title="Convert" class="md-nav__link">
|
||||||
|
Convert
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="../merge/" title="Merge" class="md-nav__link">
|
||||||
|
Merge
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
|
||||||
|
</ul>
|
||||||
|
</nav>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="md-sidebar md-sidebar--secondary" data-md-component="toc">
|
||||||
|
<div class="md-sidebar__scrollwrap">
|
||||||
|
<div class="md-sidebar__inner">
|
||||||
|
|
||||||
|
<nav class="md-nav md-nav--secondary">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<label class="md-nav__title" for="toc">Table of contents</label>
|
||||||
|
<ul class="md-nav__list" data-md-scrollfix>
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="#creating-a-simple-yaml-file" title="Creating a simple yaml file" class="md-nav__link">
|
||||||
|
Creating a simple yaml file
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="#creating-using-a-create-script" title="Creating using a create script" class="md-nav__link">
|
||||||
|
Creating using a create script
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="#keys-with-dots" title="Keys with dots" class="md-nav__link">
|
||||||
|
Keys with dots
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
</nav>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="md-content">
|
||||||
|
<article class="md-content__inner md-typeset">
|
||||||
|
|
||||||
|
|
||||||
|
<a href="https://github.com/mikefarah/yq/edit/master/docs/create.md" title="Edit this page" class="md-icon md-content__icon"></a>
|
||||||
|
|
||||||
|
|
||||||
|
<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. Currently this does not support creating multiple documents in a single yaml file.</p>
|
||||||
|
<pre><code>yq n <path> <new value>
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<h3 id="creating-a-simple-yaml-file">Creating a simple yaml file<a class="headerlink" href="#creating-a-simple-yaml-file" title="Permanent link">¶</a></h3>
|
||||||
|
<pre><code class="bash">yq n b.c cat
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<p>will output:</p>
|
||||||
|
<pre><code class="yaml">b:
|
||||||
|
c: cat
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<h3 id="creating-using-a-create-script">Creating using a create script<a class="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><code class="yaml">b.c: 3
|
||||||
|
b.e[0].name: Howdy Partner
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<p>then</p>
|
||||||
|
<pre><code class="bash">yq n -s create_instructions.yaml
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<p>will output:</p>
|
||||||
|
<pre><code class="yaml">b:
|
||||||
|
c: 3
|
||||||
|
e:
|
||||||
|
- name: Howdy Partner
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<p>You can also pipe the instructions in:</p>
|
||||||
|
<pre><code class="bash">cat create_instructions.yaml | yq n -s -
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<h3 id="keys-with-dots">Keys with dots<a class="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><code class="yaml">b:
|
||||||
|
foo.bar: 7
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<pre><code class="bash">yaml r sample.yaml 'b[foo.bar]'
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<pre><code class="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>
|
||||||
|
<p>Note that the path is in quotes to avoid the square brackets being interpreted by your shell.</p>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</article>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
|
||||||
|
|
||||||
|
<footer class="md-footer">
|
||||||
|
|
||||||
|
<div class="md-footer-nav">
|
||||||
|
<nav class="md-footer-nav__inner md-grid">
|
||||||
|
|
||||||
|
<a href="../delete/" title="Delete" class="md-flex md-footer-nav__link md-footer-nav__link--prev" rel="prev">
|
||||||
|
<div class="md-flex__cell md-flex__cell--shrink">
|
||||||
|
<i class="md-icon md-icon--arrow-back md-footer-nav__button"></i>
|
||||||
|
</div>
|
||||||
|
<div class="md-flex__cell md-flex__cell--stretch md-footer-nav__title">
|
||||||
|
<span class="md-flex__ellipsis">
|
||||||
|
<span class="md-footer-nav__direction">
|
||||||
|
Previous
|
||||||
|
</span>
|
||||||
|
Delete
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
|
||||||
|
<a href="../convert/" title="Convert" class="md-flex md-footer-nav__link md-footer-nav__link--next" rel="next">
|
||||||
|
<div class="md-flex__cell md-flex__cell--stretch md-footer-nav__title">
|
||||||
|
<span class="md-flex__ellipsis">
|
||||||
|
<span class="md-footer-nav__direction">
|
||||||
|
Next
|
||||||
|
</span>
|
||||||
|
Convert
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div class="md-flex__cell md-flex__cell--shrink">
|
||||||
|
<i class="md-icon md-icon--arrow-forward md-footer-nav__button"></i>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</nav>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="md-footer-meta md-typeset">
|
||||||
|
<div class="md-footer-meta__inner md-grid">
|
||||||
|
<div class="md-footer-copyright">
|
||||||
|
|
||||||
|
powered by
|
||||||
|
<a href="http://www.mkdocs.org">MkDocs</a>
|
||||||
|
and
|
||||||
|
<a href="https://squidfunk.github.io/mkdocs-material/">
|
||||||
|
Material for MkDocs</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="md-footer-social">
|
||||||
|
|
||||||
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
|
||||||
|
|
||||||
|
<a href="https://github.com/mikefarah" class="md-footer-social__link fa fa-github"></a>
|
||||||
|
|
||||||
|
<a href="https://www.linkedin.com/in/mike-farah-b5a75b2/" class="md-footer-social__link fa fa-linkedin"></a>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</footer>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script src="../assets/javascripts/application.6cdc17f0.js"></script>
|
||||||
|
|
||||||
|
<script>app.initialize({version:"0.17.2",url:{base:".."}})</script>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
645
docs/delete/index.html
Normal file
645
docs/delete/index.html
Normal file
@@ -0,0 +1,645 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en" class="no-js">
|
||||||
|
<head>
|
||||||
|
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||||
|
<meta http-equiv="x-ua-compatible" content="ie=edge">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<meta name="lang:clipboard.copy" content="Copy to clipboard">
|
||||||
|
|
||||||
|
<meta name="lang:clipboard.copied" content="Copied to clipboard">
|
||||||
|
|
||||||
|
<meta name="lang:search.language" content="en">
|
||||||
|
|
||||||
|
<meta name="lang:search.result.none" content="No matching documents">
|
||||||
|
|
||||||
|
<meta name="lang:search.result.one" content="1 matching document">
|
||||||
|
|
||||||
|
<meta name="lang:search.result.other" content="# matching documents">
|
||||||
|
|
||||||
|
<meta name="lang:search.tokenizer" content="[\s\-]+">
|
||||||
|
|
||||||
|
<link rel="shortcut icon" href="../assets/images/favicon.png">
|
||||||
|
<meta name="generator" content="mkdocs-0.17.2, mkdocs-material-2.2.5">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<title>Delete - Yq</title>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<link rel="stylesheet" href="../assets/stylesheets/application.bcabdff3.css">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<script src="../assets/javascripts/modernizr.1aa3b519.js"></script>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,400i,700|Roboto+Mono">
|
||||||
|
<style>body,input{font-family:"Roboto","Helvetica Neue",Helvetica,Arial,sans-serif}code,kbd,pre{font-family:"Roboto Mono","Courier New",Courier,monospace}</style>
|
||||||
|
|
||||||
|
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<svg class="md-svg">
|
||||||
|
<defs>
|
||||||
|
|
||||||
|
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="416" height="448" viewBox="0 0 416 448" id="github"><path fill="currentColor" d="M160 304q0 10-3.125 20.5t-10.75 19T128 352t-18.125-8.5-10.75-19T96 304t3.125-20.5 10.75-19T128 256t18.125 8.5 10.75 19T160 304zm160 0q0 10-3.125 20.5t-10.75 19T288 352t-18.125-8.5-10.75-19T256 304t3.125-20.5 10.75-19T288 256t18.125 8.5 10.75 19T320 304zm40 0q0-30-17.25-51T296 232q-10.25 0-48.75 5.25Q229.5 240 208 240t-39.25-2.75Q130.75 232 120 232q-29.5 0-46.75 21T56 304q0 22 8 38.375t20.25 25.75 30.5 15 35 7.375 37.25 1.75h42q20.5 0 37.25-1.75t35-7.375 30.5-15 20.25-25.75T360 304zm56-44q0 51.75-15.25 82.75-9.5 19.25-26.375 33.25t-35.25 21.5-42.5 11.875-42.875 5.5T212 416q-19.5 0-35.5-.75t-36.875-3.125-38.125-7.5-34.25-12.875T37 371.5t-21.5-28.75Q0 312 0 260q0-59.25 34-99-6.75-20.5-6.75-42.5 0-29 12.75-54.5 27 0 47.5 9.875t47.25 30.875Q171.5 96 212 96q37 0 70 8 26.25-20.5 46.75-30.25T376 64q12.75 25.5 12.75 54.5 0 21.75-6.75 42 34 40 34 99.5z"/></svg>
|
||||||
|
|
||||||
|
</defs>
|
||||||
|
</svg>
|
||||||
|
<input class="md-toggle" data-md-toggle="drawer" type="checkbox" id="drawer">
|
||||||
|
<input class="md-toggle" data-md-toggle="search" type="checkbox" id="search">
|
||||||
|
<label class="md-overlay" data-md-component="overlay" for="drawer"></label>
|
||||||
|
|
||||||
|
<header class="md-header" data-md-component="header">
|
||||||
|
<nav class="md-header-nav md-grid">
|
||||||
|
<div class="md-flex">
|
||||||
|
<div class="md-flex__cell md-flex__cell--shrink">
|
||||||
|
<a href=".." title="Yq" class="md-header-nav__button md-logo">
|
||||||
|
|
||||||
|
<i class="md-icon"></i>
|
||||||
|
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<div class="md-flex__cell md-flex__cell--shrink">
|
||||||
|
<label class="md-icon md-icon--menu md-header-nav__button" for="drawer"></label>
|
||||||
|
</div>
|
||||||
|
<div class="md-flex__cell md-flex__cell--stretch">
|
||||||
|
<div class="md-flex__ellipsis md-header-nav__title" data-md-component="title">
|
||||||
|
|
||||||
|
|
||||||
|
<span class="md-header-nav__topic">
|
||||||
|
Yq
|
||||||
|
</span>
|
||||||
|
<span class="md-header-nav__topic">
|
||||||
|
Delete
|
||||||
|
</span>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="md-flex__cell md-flex__cell--shrink">
|
||||||
|
|
||||||
|
|
||||||
|
<label class="md-icon md-icon--search md-header-nav__button" for="search"></label>
|
||||||
|
|
||||||
|
<div class="md-search" data-md-component="search" role="dialog">
|
||||||
|
<label class="md-search__overlay" for="search"></label>
|
||||||
|
<div class="md-search__inner">
|
||||||
|
<form class="md-search__form" name="search">
|
||||||
|
<input type="text" class="md-search__input" name="query" required placeholder="Search" autocapitalize="off" autocorrect="off" autocomplete="off" spellcheck="false" data-md-component="query">
|
||||||
|
<label class="md-icon md-search__icon" for="search"></label>
|
||||||
|
<button type="reset" class="md-icon md-search__icon" data-md-component="reset"></button>
|
||||||
|
</form>
|
||||||
|
<div class="md-search__output">
|
||||||
|
<div class="md-search__scrollwrap" data-md-scrollfix>
|
||||||
|
<div class="md-search-result" data-md-component="result">
|
||||||
|
<div class="md-search-result__meta">
|
||||||
|
Type to start searching
|
||||||
|
</div>
|
||||||
|
<ol class="md-search-result__list"></ol>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="md-flex__cell md-flex__cell--shrink">
|
||||||
|
<div class="md-header-nav__source">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<a href="https://github.com/mikefarah/yq/" title="Go to repository" class="md-source" data-md-source="github">
|
||||||
|
|
||||||
|
<div class="md-source__icon">
|
||||||
|
<svg viewBox="0 0 24 24" width="24" height="24">
|
||||||
|
<use xlink:href="#github" width="24" height="24"></use>
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="md-source__repository">
|
||||||
|
mikefarah/yq
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<div class="md-container">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<main class="md-main">
|
||||||
|
<div class="md-main__inner md-grid" data-md-component="container">
|
||||||
|
|
||||||
|
|
||||||
|
<div class="md-sidebar md-sidebar--primary" data-md-component="navigation">
|
||||||
|
<div class="md-sidebar__scrollwrap">
|
||||||
|
<div class="md-sidebar__inner">
|
||||||
|
<nav class="md-nav md-nav--primary" data-md-level="0">
|
||||||
|
<label class="md-nav__title md-nav__title--site" for="drawer">
|
||||||
|
<span class="md-nav__button md-logo">
|
||||||
|
|
||||||
|
<i class="md-icon"></i>
|
||||||
|
|
||||||
|
</span>
|
||||||
|
Yq
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<div class="md-nav__source">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<a href="https://github.com/mikefarah/yq/" title="Go to repository" class="md-source" data-md-source="github">
|
||||||
|
|
||||||
|
<div class="md-source__icon">
|
||||||
|
<svg viewBox="0 0 24 24" width="24" height="24">
|
||||||
|
<use xlink:href="#github" width="24" height="24"></use>
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="md-source__repository">
|
||||||
|
mikefarah/yq
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<ul class="md-nav__list" data-md-scrollfix>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href=".." title="Install" class="md-nav__link">
|
||||||
|
Install
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="../read/" title="Read" class="md-nav__link">
|
||||||
|
Read
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="../write/" title="Write/Update" class="md-nav__link">
|
||||||
|
Write/Update
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<li class="md-nav__item md-nav__item--active">
|
||||||
|
|
||||||
|
<input class="md-toggle md-nav__toggle" data-md-toggle="toc" type="checkbox" id="toc">
|
||||||
|
|
||||||
|
|
||||||
|
<label class="md-nav__link md-nav__link--active" for="toc">
|
||||||
|
Delete
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<a href="./" title="Delete" class="md-nav__link md-nav__link--active">
|
||||||
|
Delete
|
||||||
|
</a>
|
||||||
|
|
||||||
|
|
||||||
|
<nav class="md-nav md-nav--secondary">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<label class="md-nav__title" for="toc">Table of contents</label>
|
||||||
|
<ul class="md-nav__list" data-md-scrollfix>
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="#to-stdout" title="To Stdout" class="md-nav__link">
|
||||||
|
To Stdout
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="#from-stdin" title="From STDIN" class="md-nav__link">
|
||||||
|
From STDIN
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="#deleting-array-elements" title="Deleting array elements" class="md-nav__link">
|
||||||
|
Deleting array elements
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="#deleting-nodes-in-place" title="Deleting nodes in-place" class="md-nav__link">
|
||||||
|
Deleting nodes in-place
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="#multiple-documents-delete-from-single-document" title="Multiple Documents - delete from single document" class="md-nav__link">
|
||||||
|
Multiple Documents - delete from single document
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="#multiple-documents-delete-from-all-documents" title="Multiple Documents - delete from all documents" class="md-nav__link">
|
||||||
|
Multiple Documents - delete from all documents
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="#keys-with-dots" title="Keys with dots" class="md-nav__link">
|
||||||
|
Keys with dots
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="../create/" title="Create" class="md-nav__link">
|
||||||
|
Create
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="../convert/" title="Convert" class="md-nav__link">
|
||||||
|
Convert
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="../merge/" title="Merge" class="md-nav__link">
|
||||||
|
Merge
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
|
||||||
|
</ul>
|
||||||
|
</nav>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="md-sidebar md-sidebar--secondary" data-md-component="toc">
|
||||||
|
<div class="md-sidebar__scrollwrap">
|
||||||
|
<div class="md-sidebar__inner">
|
||||||
|
|
||||||
|
<nav class="md-nav md-nav--secondary">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<label class="md-nav__title" for="toc">Table of contents</label>
|
||||||
|
<ul class="md-nav__list" data-md-scrollfix>
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="#to-stdout" title="To Stdout" class="md-nav__link">
|
||||||
|
To Stdout
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="#from-stdin" title="From STDIN" class="md-nav__link">
|
||||||
|
From STDIN
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="#deleting-array-elements" title="Deleting array elements" class="md-nav__link">
|
||||||
|
Deleting array elements
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="#deleting-nodes-in-place" title="Deleting nodes in-place" class="md-nav__link">
|
||||||
|
Deleting nodes in-place
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="#multiple-documents-delete-from-single-document" title="Multiple Documents - delete from single document" class="md-nav__link">
|
||||||
|
Multiple Documents - delete from single document
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="#multiple-documents-delete-from-all-documents" title="Multiple Documents - delete from all documents" class="md-nav__link">
|
||||||
|
Multiple Documents - delete from all documents
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="#keys-with-dots" title="Keys with dots" class="md-nav__link">
|
||||||
|
Keys with dots
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
</nav>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="md-content">
|
||||||
|
<article class="md-content__inner md-typeset">
|
||||||
|
|
||||||
|
|
||||||
|
<a href="https://github.com/mikefarah/yq/edit/master/docs/delete.md" title="Edit this page" class="md-icon md-content__icon"></a>
|
||||||
|
|
||||||
|
|
||||||
|
<h1>Delete</h1>
|
||||||
|
|
||||||
|
<pre><code>yq d <yaml_file> <path_to_delete>
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<h3 id="to-stdout">To Stdout<a class="headerlink" href="#to-stdout" title="Permanent link">¶</a></h3>
|
||||||
|
<p>Given a sample.yaml file of:</p>
|
||||||
|
<pre><code class="yaml">b:
|
||||||
|
c: 2
|
||||||
|
apples: green
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<p>then</p>
|
||||||
|
<pre><code class="bash">yq d sample.yaml b.c
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<p>will output:</p>
|
||||||
|
<pre><code class="yaml">b:
|
||||||
|
apples: green
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<h3 id="from-stdin">From STDIN<a class="headerlink" href="#from-stdin" title="Permanent link">¶</a></h3>
|
||||||
|
<pre><code class="bash">cat sample.yaml | yq d - b.c
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<h3 id="deleting-array-elements">Deleting array elements<a class="headerlink" href="#deleting-array-elements" title="Permanent link">¶</a></h3>
|
||||||
|
<p>Given a sample.yaml file of:</p>
|
||||||
|
<pre><code class="yaml">b:
|
||||||
|
c:
|
||||||
|
- 1
|
||||||
|
- 2
|
||||||
|
- 3
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<p>then</p>
|
||||||
|
<pre><code class="bash">yq d sample.yaml 'b.c[1]'
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<p>will output:</p>
|
||||||
|
<pre><code class="yaml">b:
|
||||||
|
c:
|
||||||
|
- 1
|
||||||
|
- 3
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<h3 id="deleting-nodes-in-place">Deleting nodes in-place<a class="headerlink" href="#deleting-nodes-in-place" title="Permanent link">¶</a></h3>
|
||||||
|
<p>Given a sample.yaml file of:</p>
|
||||||
|
<pre><code class="yaml">b:
|
||||||
|
c: 2
|
||||||
|
apples: green
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<p>then</p>
|
||||||
|
<pre><code class="bash">yq d -i sample.yaml b.c
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<p>will update the sample.yaml file so that the 'c' node is deleted</p>
|
||||||
|
<h3 id="multiple-documents-delete-from-single-document">Multiple Documents - delete from single document<a class="headerlink" href="#multiple-documents-delete-from-single-document" title="Permanent link">¶</a></h3>
|
||||||
|
<p>Given a sample.yaml file of:</p>
|
||||||
|
<pre><code class="yaml">something: else
|
||||||
|
field: leaveMe
|
||||||
|
---
|
||||||
|
b:
|
||||||
|
c: 2
|
||||||
|
field: deleteMe
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<p>then</p>
|
||||||
|
<pre><code class="bash">yq w -d1 sample.yaml field
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<p>will output:</p>
|
||||||
|
<pre><code class="yaml">something: else
|
||||||
|
field: leaveMe
|
||||||
|
---
|
||||||
|
b:
|
||||||
|
c: 2
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<h3 id="multiple-documents-delete-from-all-documents">Multiple Documents - delete from all documents<a class="headerlink" href="#multiple-documents-delete-from-all-documents" title="Permanent link">¶</a></h3>
|
||||||
|
<p>Given a sample.yaml file of:</p>
|
||||||
|
<pre><code class="yaml">something: else
|
||||||
|
field: deleteMe
|
||||||
|
---
|
||||||
|
b:
|
||||||
|
c: 2
|
||||||
|
field: deleteMeToo
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<p>then</p>
|
||||||
|
<pre><code class="bash">yq w -d'*' sample.yaml field
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<p>will output:</p>
|
||||||
|
<pre><code class="yaml">something: else
|
||||||
|
---
|
||||||
|
b:
|
||||||
|
c: 2
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<p>Note that '*' is in quotes to avoid being interpreted by your shell.</p>
|
||||||
|
<h3 id="keys-with-dots">Keys with dots<a class="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><code class="yaml">b:
|
||||||
|
foo.bar: 7
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<pre><code class="bash">yaml r sample.yaml 'b[foo.bar]'
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<pre><code class="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>
|
||||||
|
<p>Note that the path is in quotes to avoid the square brackets being interpreted by your shell.</p>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</article>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
|
||||||
|
|
||||||
|
<footer class="md-footer">
|
||||||
|
|
||||||
|
<div class="md-footer-nav">
|
||||||
|
<nav class="md-footer-nav__inner md-grid">
|
||||||
|
|
||||||
|
<a href="../write/" title="Write/Update" class="md-flex md-footer-nav__link md-footer-nav__link--prev" rel="prev">
|
||||||
|
<div class="md-flex__cell md-flex__cell--shrink">
|
||||||
|
<i class="md-icon md-icon--arrow-back md-footer-nav__button"></i>
|
||||||
|
</div>
|
||||||
|
<div class="md-flex__cell md-flex__cell--stretch md-footer-nav__title">
|
||||||
|
<span class="md-flex__ellipsis">
|
||||||
|
<span class="md-footer-nav__direction">
|
||||||
|
Previous
|
||||||
|
</span>
|
||||||
|
Write/Update
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
|
||||||
|
<a href="../create/" title="Create" class="md-flex md-footer-nav__link md-footer-nav__link--next" rel="next">
|
||||||
|
<div class="md-flex__cell md-flex__cell--stretch md-footer-nav__title">
|
||||||
|
<span class="md-flex__ellipsis">
|
||||||
|
<span class="md-footer-nav__direction">
|
||||||
|
Next
|
||||||
|
</span>
|
||||||
|
Create
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div class="md-flex__cell md-flex__cell--shrink">
|
||||||
|
<i class="md-icon md-icon--arrow-forward md-footer-nav__button"></i>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</nav>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="md-footer-meta md-typeset">
|
||||||
|
<div class="md-footer-meta__inner md-grid">
|
||||||
|
<div class="md-footer-copyright">
|
||||||
|
|
||||||
|
powered by
|
||||||
|
<a href="http://www.mkdocs.org">MkDocs</a>
|
||||||
|
and
|
||||||
|
<a href="https://squidfunk.github.io/mkdocs-material/">
|
||||||
|
Material for MkDocs</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="md-footer-social">
|
||||||
|
|
||||||
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
|
||||||
|
|
||||||
|
<a href="https://github.com/mikefarah" class="md-footer-social__link fa fa-github"></a>
|
||||||
|
|
||||||
|
<a href="https://www.linkedin.com/in/mike-farah-b5a75b2/" class="md-footer-social__link fa fa-linkedin"></a>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</footer>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script src="../assets/javascripts/application.6cdc17f0.js"></script>
|
||||||
|
|
||||||
|
<script>app.initialize({version:"0.17.2",url:{base:".."}})</script>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
461
docs/index.html
Normal file
461
docs/index.html
Normal file
@@ -0,0 +1,461 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en" class="no-js">
|
||||||
|
<head>
|
||||||
|
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||||
|
<meta http-equiv="x-ua-compatible" content="ie=edge">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<meta name="lang:clipboard.copy" content="Copy to clipboard">
|
||||||
|
|
||||||
|
<meta name="lang:clipboard.copied" content="Copied to clipboard">
|
||||||
|
|
||||||
|
<meta name="lang:search.language" content="en">
|
||||||
|
|
||||||
|
<meta name="lang:search.result.none" content="No matching documents">
|
||||||
|
|
||||||
|
<meta name="lang:search.result.one" content="1 matching document">
|
||||||
|
|
||||||
|
<meta name="lang:search.result.other" content="# matching documents">
|
||||||
|
|
||||||
|
<meta name="lang:search.tokenizer" content="[\s\-]+">
|
||||||
|
|
||||||
|
<link rel="shortcut icon" href="./assets/images/favicon.png">
|
||||||
|
<meta name="generator" content="mkdocs-0.17.2, mkdocs-material-2.2.5">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<title>Yq</title>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<link rel="stylesheet" href="./assets/stylesheets/application.bcabdff3.css">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<script src="./assets/javascripts/modernizr.1aa3b519.js"></script>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,400i,700|Roboto+Mono">
|
||||||
|
<style>body,input{font-family:"Roboto","Helvetica Neue",Helvetica,Arial,sans-serif}code,kbd,pre{font-family:"Roboto Mono","Courier New",Courier,monospace}</style>
|
||||||
|
|
||||||
|
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<svg class="md-svg">
|
||||||
|
<defs>
|
||||||
|
|
||||||
|
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="416" height="448" viewBox="0 0 416 448" id="github"><path fill="currentColor" d="M160 304q0 10-3.125 20.5t-10.75 19T128 352t-18.125-8.5-10.75-19T96 304t3.125-20.5 10.75-19T128 256t18.125 8.5 10.75 19T160 304zm160 0q0 10-3.125 20.5t-10.75 19T288 352t-18.125-8.5-10.75-19T256 304t3.125-20.5 10.75-19T288 256t18.125 8.5 10.75 19T320 304zm40 0q0-30-17.25-51T296 232q-10.25 0-48.75 5.25Q229.5 240 208 240t-39.25-2.75Q130.75 232 120 232q-29.5 0-46.75 21T56 304q0 22 8 38.375t20.25 25.75 30.5 15 35 7.375 37.25 1.75h42q20.5 0 37.25-1.75t35-7.375 30.5-15 20.25-25.75T360 304zm56-44q0 51.75-15.25 82.75-9.5 19.25-26.375 33.25t-35.25 21.5-42.5 11.875-42.875 5.5T212 416q-19.5 0-35.5-.75t-36.875-3.125-38.125-7.5-34.25-12.875T37 371.5t-21.5-28.75Q0 312 0 260q0-59.25 34-99-6.75-20.5-6.75-42.5 0-29 12.75-54.5 27 0 47.5 9.875t47.25 30.875Q171.5 96 212 96q37 0 70 8 26.25-20.5 46.75-30.25T376 64q12.75 25.5 12.75 54.5 0 21.75-6.75 42 34 40 34 99.5z"/></svg>
|
||||||
|
|
||||||
|
</defs>
|
||||||
|
</svg>
|
||||||
|
<input class="md-toggle" data-md-toggle="drawer" type="checkbox" id="drawer">
|
||||||
|
<input class="md-toggle" data-md-toggle="search" type="checkbox" id="search">
|
||||||
|
<label class="md-overlay" data-md-component="overlay" for="drawer"></label>
|
||||||
|
|
||||||
|
<header class="md-header" data-md-component="header">
|
||||||
|
<nav class="md-header-nav md-grid">
|
||||||
|
<div class="md-flex">
|
||||||
|
<div class="md-flex__cell md-flex__cell--shrink">
|
||||||
|
<a href="." title="Yq" class="md-header-nav__button md-logo">
|
||||||
|
|
||||||
|
<i class="md-icon"></i>
|
||||||
|
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<div class="md-flex__cell md-flex__cell--shrink">
|
||||||
|
<label class="md-icon md-icon--menu md-header-nav__button" for="drawer"></label>
|
||||||
|
</div>
|
||||||
|
<div class="md-flex__cell md-flex__cell--stretch">
|
||||||
|
<div class="md-flex__ellipsis md-header-nav__title" data-md-component="title">
|
||||||
|
|
||||||
|
|
||||||
|
<span class="md-header-nav__topic">
|
||||||
|
Yq
|
||||||
|
</span>
|
||||||
|
<span class="md-header-nav__topic">
|
||||||
|
Install
|
||||||
|
</span>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="md-flex__cell md-flex__cell--shrink">
|
||||||
|
|
||||||
|
|
||||||
|
<label class="md-icon md-icon--search md-header-nav__button" for="search"></label>
|
||||||
|
|
||||||
|
<div class="md-search" data-md-component="search" role="dialog">
|
||||||
|
<label class="md-search__overlay" for="search"></label>
|
||||||
|
<div class="md-search__inner">
|
||||||
|
<form class="md-search__form" name="search">
|
||||||
|
<input type="text" class="md-search__input" name="query" required placeholder="Search" autocapitalize="off" autocorrect="off" autocomplete="off" spellcheck="false" data-md-component="query">
|
||||||
|
<label class="md-icon md-search__icon" for="search"></label>
|
||||||
|
<button type="reset" class="md-icon md-search__icon" data-md-component="reset"></button>
|
||||||
|
</form>
|
||||||
|
<div class="md-search__output">
|
||||||
|
<div class="md-search__scrollwrap" data-md-scrollfix>
|
||||||
|
<div class="md-search-result" data-md-component="result">
|
||||||
|
<div class="md-search-result__meta">
|
||||||
|
Type to start searching
|
||||||
|
</div>
|
||||||
|
<ol class="md-search-result__list"></ol>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="md-flex__cell md-flex__cell--shrink">
|
||||||
|
<div class="md-header-nav__source">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<a href="https://github.com/mikefarah/yq/" title="Go to repository" class="md-source" data-md-source="github">
|
||||||
|
|
||||||
|
<div class="md-source__icon">
|
||||||
|
<svg viewBox="0 0 24 24" width="24" height="24">
|
||||||
|
<use xlink:href="#github" width="24" height="24"></use>
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="md-source__repository">
|
||||||
|
mikefarah/yq
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<div class="md-container">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<main class="md-main">
|
||||||
|
<div class="md-main__inner md-grid" data-md-component="container">
|
||||||
|
|
||||||
|
|
||||||
|
<div class="md-sidebar md-sidebar--primary" data-md-component="navigation">
|
||||||
|
<div class="md-sidebar__scrollwrap">
|
||||||
|
<div class="md-sidebar__inner">
|
||||||
|
<nav class="md-nav md-nav--primary" data-md-level="0">
|
||||||
|
<label class="md-nav__title md-nav__title--site" for="drawer">
|
||||||
|
<span class="md-nav__button md-logo">
|
||||||
|
|
||||||
|
<i class="md-icon"></i>
|
||||||
|
|
||||||
|
</span>
|
||||||
|
Yq
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<div class="md-nav__source">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<a href="https://github.com/mikefarah/yq/" title="Go to repository" class="md-source" data-md-source="github">
|
||||||
|
|
||||||
|
<div class="md-source__icon">
|
||||||
|
<svg viewBox="0 0 24 24" width="24" height="24">
|
||||||
|
<use xlink:href="#github" width="24" height="24"></use>
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="md-source__repository">
|
||||||
|
mikefarah/yq
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<ul class="md-nav__list" data-md-scrollfix>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<li class="md-nav__item md-nav__item--active">
|
||||||
|
|
||||||
|
<input class="md-toggle md-nav__toggle" data-md-toggle="toc" type="checkbox" id="toc">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<label class="md-nav__link md-nav__link--active" for="toc">
|
||||||
|
Install
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<a href="." title="Install" class="md-nav__link md-nav__link--active">
|
||||||
|
Install
|
||||||
|
</a>
|
||||||
|
|
||||||
|
|
||||||
|
<nav class="md-nav md-nav--secondary">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<label class="md-nav__title" for="toc">Table of contents</label>
|
||||||
|
<ul class="md-nav__list" data-md-scrollfix>
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="#install" title="Install" class="md-nav__link">
|
||||||
|
Install
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="read/" title="Read" class="md-nav__link">
|
||||||
|
Read
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="write/" title="Write/Update" class="md-nav__link">
|
||||||
|
Write/Update
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="delete/" title="Delete" class="md-nav__link">
|
||||||
|
Delete
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="create/" title="Create" class="md-nav__link">
|
||||||
|
Create
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="convert/" title="Convert" class="md-nav__link">
|
||||||
|
Convert
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="merge/" title="Merge" class="md-nav__link">
|
||||||
|
Merge
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
|
||||||
|
</ul>
|
||||||
|
</nav>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="md-sidebar md-sidebar--secondary" data-md-component="toc">
|
||||||
|
<div class="md-sidebar__scrollwrap">
|
||||||
|
<div class="md-sidebar__inner">
|
||||||
|
|
||||||
|
<nav class="md-nav md-nav--secondary">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<label class="md-nav__title" for="toc">Table of contents</label>
|
||||||
|
<ul class="md-nav__list" data-md-scrollfix>
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="#install" title="Install" class="md-nav__link">
|
||||||
|
Install
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
</nav>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="md-content">
|
||||||
|
<article class="md-content__inner md-typeset">
|
||||||
|
|
||||||
|
|
||||||
|
<a href="https://github.com/mikefarah/yq/edit/master/docs/index.md" title="Edit this page" class="md-icon md-content__icon"></a>
|
||||||
|
|
||||||
|
|
||||||
|
<h1 id="yq">yq<a class="headerlink" href="#yq" title="Permanent link">¶</a></h1>
|
||||||
|
<p>yq is a lightweight and portable command-line YAML processor</p>
|
||||||
|
<p>The aim of the project is to be the <a href="https://github.com/stedolan/jq">jq</a> or sed of yaml files.</p>
|
||||||
|
<h2 id="install">Install<a class="headerlink" href="#install" title="Permanent link">¶</a></h2>
|
||||||
|
<p>On MacOS:</p>
|
||||||
|
<pre><code>brew install yq
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<p>On Ubuntu and other Linux distros supporting <code>snap</code> packages:</p>
|
||||||
|
<pre><code>snap install yq
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<p>On Ubuntu 16.04 or higher from Debian package:</p>
|
||||||
|
<pre><code>sudo add-apt-repository ppa:rmescandon/yq
|
||||||
|
sudo apt update
|
||||||
|
sudo apt install yq -y
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<p>or, <a href="https://github.com/mikefarah/yq/releases/latest">Download latest binary</a> or alternatively:</p>
|
||||||
|
<pre><code>go get gopkg.in/mikefarah/yq.v2
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<p><a href="https://github.com/mikefarah/yq">View on GitHub</a></p>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</article>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
|
||||||
|
|
||||||
|
<footer class="md-footer">
|
||||||
|
|
||||||
|
<div class="md-footer-nav">
|
||||||
|
<nav class="md-footer-nav__inner md-grid">
|
||||||
|
|
||||||
|
|
||||||
|
<a href="read/" title="Read" class="md-flex md-footer-nav__link md-footer-nav__link--next" rel="next">
|
||||||
|
<div class="md-flex__cell md-flex__cell--stretch md-footer-nav__title">
|
||||||
|
<span class="md-flex__ellipsis">
|
||||||
|
<span class="md-footer-nav__direction">
|
||||||
|
Next
|
||||||
|
</span>
|
||||||
|
Read
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div class="md-flex__cell md-flex__cell--shrink">
|
||||||
|
<i class="md-icon md-icon--arrow-forward md-footer-nav__button"></i>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</nav>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="md-footer-meta md-typeset">
|
||||||
|
<div class="md-footer-meta__inner md-grid">
|
||||||
|
<div class="md-footer-copyright">
|
||||||
|
|
||||||
|
powered by
|
||||||
|
<a href="http://www.mkdocs.org">MkDocs</a>
|
||||||
|
and
|
||||||
|
<a href="https://squidfunk.github.io/mkdocs-material/">
|
||||||
|
Material for MkDocs</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="md-footer-social">
|
||||||
|
|
||||||
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
|
||||||
|
|
||||||
|
<a href="https://github.com/mikefarah" class="md-footer-social__link fa fa-github"></a>
|
||||||
|
|
||||||
|
<a href="https://www.linkedin.com/in/mike-farah-b5a75b2/" class="md-footer-social__link fa fa-linkedin"></a>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</footer>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script src="./assets/javascripts/application.6cdc17f0.js"></script>
|
||||||
|
|
||||||
|
<script>app.initialize({version:"0.17.2",url:{base:"."}})</script>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
649
docs/merge/index.html
Normal file
649
docs/merge/index.html
Normal file
@@ -0,0 +1,649 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en" class="no-js">
|
||||||
|
<head>
|
||||||
|
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||||
|
<meta http-equiv="x-ua-compatible" content="ie=edge">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<meta name="lang:clipboard.copy" content="Copy to clipboard">
|
||||||
|
|
||||||
|
<meta name="lang:clipboard.copied" content="Copied to clipboard">
|
||||||
|
|
||||||
|
<meta name="lang:search.language" content="en">
|
||||||
|
|
||||||
|
<meta name="lang:search.result.none" content="No matching documents">
|
||||||
|
|
||||||
|
<meta name="lang:search.result.one" content="1 matching document">
|
||||||
|
|
||||||
|
<meta name="lang:search.result.other" content="# matching documents">
|
||||||
|
|
||||||
|
<meta name="lang:search.tokenizer" content="[\s\-]+">
|
||||||
|
|
||||||
|
<link rel="shortcut icon" href="../assets/images/favicon.png">
|
||||||
|
<meta name="generator" content="mkdocs-0.17.2, mkdocs-material-2.2.5">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<title>Merge - Yq</title>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<link rel="stylesheet" href="../assets/stylesheets/application.bcabdff3.css">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<script src="../assets/javascripts/modernizr.1aa3b519.js"></script>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,400i,700|Roboto+Mono">
|
||||||
|
<style>body,input{font-family:"Roboto","Helvetica Neue",Helvetica,Arial,sans-serif}code,kbd,pre{font-family:"Roboto Mono","Courier New",Courier,monospace}</style>
|
||||||
|
|
||||||
|
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<svg class="md-svg">
|
||||||
|
<defs>
|
||||||
|
|
||||||
|
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="416" height="448" viewBox="0 0 416 448" id="github"><path fill="currentColor" d="M160 304q0 10-3.125 20.5t-10.75 19T128 352t-18.125-8.5-10.75-19T96 304t3.125-20.5 10.75-19T128 256t18.125 8.5 10.75 19T160 304zm160 0q0 10-3.125 20.5t-10.75 19T288 352t-18.125-8.5-10.75-19T256 304t3.125-20.5 10.75-19T288 256t18.125 8.5 10.75 19T320 304zm40 0q0-30-17.25-51T296 232q-10.25 0-48.75 5.25Q229.5 240 208 240t-39.25-2.75Q130.75 232 120 232q-29.5 0-46.75 21T56 304q0 22 8 38.375t20.25 25.75 30.5 15 35 7.375 37.25 1.75h42q20.5 0 37.25-1.75t35-7.375 30.5-15 20.25-25.75T360 304zm56-44q0 51.75-15.25 82.75-9.5 19.25-26.375 33.25t-35.25 21.5-42.5 11.875-42.875 5.5T212 416q-19.5 0-35.5-.75t-36.875-3.125-38.125-7.5-34.25-12.875T37 371.5t-21.5-28.75Q0 312 0 260q0-59.25 34-99-6.75-20.5-6.75-42.5 0-29 12.75-54.5 27 0 47.5 9.875t47.25 30.875Q171.5 96 212 96q37 0 70 8 26.25-20.5 46.75-30.25T376 64q12.75 25.5 12.75 54.5 0 21.75-6.75 42 34 40 34 99.5z"/></svg>
|
||||||
|
|
||||||
|
</defs>
|
||||||
|
</svg>
|
||||||
|
<input class="md-toggle" data-md-toggle="drawer" type="checkbox" id="drawer">
|
||||||
|
<input class="md-toggle" data-md-toggle="search" type="checkbox" id="search">
|
||||||
|
<label class="md-overlay" data-md-component="overlay" for="drawer"></label>
|
||||||
|
|
||||||
|
<header class="md-header" data-md-component="header">
|
||||||
|
<nav class="md-header-nav md-grid">
|
||||||
|
<div class="md-flex">
|
||||||
|
<div class="md-flex__cell md-flex__cell--shrink">
|
||||||
|
<a href=".." title="Yq" class="md-header-nav__button md-logo">
|
||||||
|
|
||||||
|
<i class="md-icon"></i>
|
||||||
|
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<div class="md-flex__cell md-flex__cell--shrink">
|
||||||
|
<label class="md-icon md-icon--menu md-header-nav__button" for="drawer"></label>
|
||||||
|
</div>
|
||||||
|
<div class="md-flex__cell md-flex__cell--stretch">
|
||||||
|
<div class="md-flex__ellipsis md-header-nav__title" data-md-component="title">
|
||||||
|
|
||||||
|
|
||||||
|
<span class="md-header-nav__topic">
|
||||||
|
Yq
|
||||||
|
</span>
|
||||||
|
<span class="md-header-nav__topic">
|
||||||
|
Merge
|
||||||
|
</span>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="md-flex__cell md-flex__cell--shrink">
|
||||||
|
|
||||||
|
|
||||||
|
<label class="md-icon md-icon--search md-header-nav__button" for="search"></label>
|
||||||
|
|
||||||
|
<div class="md-search" data-md-component="search" role="dialog">
|
||||||
|
<label class="md-search__overlay" for="search"></label>
|
||||||
|
<div class="md-search__inner">
|
||||||
|
<form class="md-search__form" name="search">
|
||||||
|
<input type="text" class="md-search__input" name="query" required placeholder="Search" autocapitalize="off" autocorrect="off" autocomplete="off" spellcheck="false" data-md-component="query">
|
||||||
|
<label class="md-icon md-search__icon" for="search"></label>
|
||||||
|
<button type="reset" class="md-icon md-search__icon" data-md-component="reset"></button>
|
||||||
|
</form>
|
||||||
|
<div class="md-search__output">
|
||||||
|
<div class="md-search__scrollwrap" data-md-scrollfix>
|
||||||
|
<div class="md-search-result" data-md-component="result">
|
||||||
|
<div class="md-search-result__meta">
|
||||||
|
Type to start searching
|
||||||
|
</div>
|
||||||
|
<ol class="md-search-result__list"></ol>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="md-flex__cell md-flex__cell--shrink">
|
||||||
|
<div class="md-header-nav__source">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<a href="https://github.com/mikefarah/yq/" title="Go to repository" class="md-source" data-md-source="github">
|
||||||
|
|
||||||
|
<div class="md-source__icon">
|
||||||
|
<svg viewBox="0 0 24 24" width="24" height="24">
|
||||||
|
<use xlink:href="#github" width="24" height="24"></use>
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="md-source__repository">
|
||||||
|
mikefarah/yq
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<div class="md-container">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<main class="md-main">
|
||||||
|
<div class="md-main__inner md-grid" data-md-component="container">
|
||||||
|
|
||||||
|
|
||||||
|
<div class="md-sidebar md-sidebar--primary" data-md-component="navigation">
|
||||||
|
<div class="md-sidebar__scrollwrap">
|
||||||
|
<div class="md-sidebar__inner">
|
||||||
|
<nav class="md-nav md-nav--primary" data-md-level="0">
|
||||||
|
<label class="md-nav__title md-nav__title--site" for="drawer">
|
||||||
|
<span class="md-nav__button md-logo">
|
||||||
|
|
||||||
|
<i class="md-icon"></i>
|
||||||
|
|
||||||
|
</span>
|
||||||
|
Yq
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<div class="md-nav__source">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<a href="https://github.com/mikefarah/yq/" title="Go to repository" class="md-source" data-md-source="github">
|
||||||
|
|
||||||
|
<div class="md-source__icon">
|
||||||
|
<svg viewBox="0 0 24 24" width="24" height="24">
|
||||||
|
<use xlink:href="#github" width="24" height="24"></use>
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="md-source__repository">
|
||||||
|
mikefarah/yq
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<ul class="md-nav__list" data-md-scrollfix>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href=".." title="Install" class="md-nav__link">
|
||||||
|
Install
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="../read/" title="Read" class="md-nav__link">
|
||||||
|
Read
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="../write/" title="Write/Update" class="md-nav__link">
|
||||||
|
Write/Update
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="../delete/" title="Delete" class="md-nav__link">
|
||||||
|
Delete
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="../create/" title="Create" class="md-nav__link">
|
||||||
|
Create
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="../convert/" title="Convert" class="md-nav__link">
|
||||||
|
Convert
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<li class="md-nav__item md-nav__item--active">
|
||||||
|
|
||||||
|
<input class="md-toggle md-nav__toggle" data-md-toggle="toc" type="checkbox" id="toc">
|
||||||
|
|
||||||
|
|
||||||
|
<label class="md-nav__link md-nav__link--active" for="toc">
|
||||||
|
Merge
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<a href="./" title="Merge" class="md-nav__link md-nav__link--active">
|
||||||
|
Merge
|
||||||
|
</a>
|
||||||
|
|
||||||
|
|
||||||
|
<nav class="md-nav md-nav--secondary">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<label class="md-nav__title" for="toc">Table of contents</label>
|
||||||
|
<ul class="md-nav__list" data-md-scrollfix>
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="#to-stdout" title="To Stdout" class="md-nav__link">
|
||||||
|
To Stdout
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="#updating-files-in-place" title="Updating files in-place" class="md-nav__link">
|
||||||
|
Updating files in-place
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="#overwrite-values" title="Overwrite values" class="md-nav__link">
|
||||||
|
Overwrite values
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="#overwrite-values-with-arrays" title="Overwrite values with arrays" class="md-nav__link">
|
||||||
|
Overwrite values with arrays
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="#multiple-documents-merge-into-single-document" title="Multiple Documents - merge into single document" class="md-nav__link">
|
||||||
|
Multiple Documents - merge into single document
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="#multiple-documents-merge-into-all-documents" title="Multiple Documents - merge into all documents" class="md-nav__link">
|
||||||
|
Multiple Documents - merge into all documents
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
|
||||||
|
</ul>
|
||||||
|
</nav>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="md-sidebar md-sidebar--secondary" data-md-component="toc">
|
||||||
|
<div class="md-sidebar__scrollwrap">
|
||||||
|
<div class="md-sidebar__inner">
|
||||||
|
|
||||||
|
<nav class="md-nav md-nav--secondary">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<label class="md-nav__title" for="toc">Table of contents</label>
|
||||||
|
<ul class="md-nav__list" data-md-scrollfix>
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="#to-stdout" title="To Stdout" class="md-nav__link">
|
||||||
|
To Stdout
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="#updating-files-in-place" title="Updating files in-place" class="md-nav__link">
|
||||||
|
Updating files in-place
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="#overwrite-values" title="Overwrite values" class="md-nav__link">
|
||||||
|
Overwrite values
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="#overwrite-values-with-arrays" title="Overwrite values with arrays" class="md-nav__link">
|
||||||
|
Overwrite values with arrays
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="#multiple-documents-merge-into-single-document" title="Multiple Documents - merge into single document" class="md-nav__link">
|
||||||
|
Multiple Documents - merge into single document
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="#multiple-documents-merge-into-all-documents" title="Multiple Documents - merge into all documents" class="md-nav__link">
|
||||||
|
Multiple Documents - merge into all documents
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
</nav>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="md-content">
|
||||||
|
<article class="md-content__inner md-typeset">
|
||||||
|
|
||||||
|
|
||||||
|
<a href="https://github.com/mikefarah/yq/edit/master/docs/merge.md" title="Edit this page" class="md-icon md-content__icon"></a>
|
||||||
|
|
||||||
|
|
||||||
|
<h1>Merge</h1>
|
||||||
|
|
||||||
|
<p>Yaml files can be merged using the 'merge' command. Each additional file merged with the first file will
|
||||||
|
set values for any key not existing already or where the key has no value.</p>
|
||||||
|
<pre><code>yq m <yaml_file> <path>...
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<h3 id="to-stdout">To Stdout<a class="headerlink" href="#to-stdout" title="Permanent link">¶</a></h3>
|
||||||
|
<p>Given a data1.yaml file of:</p>
|
||||||
|
<pre><code class="yaml">a: simple
|
||||||
|
b: [1, 2]
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<p>and data2.yaml file of:</p>
|
||||||
|
<pre><code class="yaml">a: other
|
||||||
|
c:
|
||||||
|
test: 1
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<p>then</p>
|
||||||
|
<pre><code class="bash">yq m data1.yaml data2.yaml
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<p>will output:</p>
|
||||||
|
<pre><code class="yaml">a: simple
|
||||||
|
b: [1, 2]
|
||||||
|
c:
|
||||||
|
test: 1
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<h3 id="updating-files-in-place">Updating files in-place<a class="headerlink" href="#updating-files-in-place" title="Permanent link">¶</a></h3>
|
||||||
|
<p>Given a data1.yaml file of:</p>
|
||||||
|
<pre><code class="yaml">a: simple
|
||||||
|
b: [1, 2]
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<p>and data2.yaml file of:</p>
|
||||||
|
<pre><code class="yaml">a: other
|
||||||
|
c:
|
||||||
|
test: 1
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<p>then</p>
|
||||||
|
<pre><code class="bash">yq m -i data1.yaml data2.yaml
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<p>will update the data1.yaml file so that the value of 'c' is 'test: 1'.</p>
|
||||||
|
<h3 id="overwrite-values">Overwrite values<a class="headerlink" href="#overwrite-values" title="Permanent link">¶</a></h3>
|
||||||
|
<p>Given a data1.yaml file of:</p>
|
||||||
|
<pre><code class="yaml">a: simple
|
||||||
|
b: [1, 2]
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<p>and data2.yaml file of:</p>
|
||||||
|
<pre><code class="yaml">a: other
|
||||||
|
c:
|
||||||
|
test: 1
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<p>then</p>
|
||||||
|
<pre><code class="bash">yq m -x data1.yaml data2.yaml
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<p>will output:</p>
|
||||||
|
<pre><code class="yaml">a: other
|
||||||
|
b: [1, 2]
|
||||||
|
c:
|
||||||
|
test: 1
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<h3 id="overwrite-values-with-arrays">Overwrite values with arrays<a class="headerlink" href="#overwrite-values-with-arrays" title="Permanent link">¶</a></h3>
|
||||||
|
<p>Given a data1.yaml file of:</p>
|
||||||
|
<pre><code class="yaml">a: simple
|
||||||
|
b: [1, 2]
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<p>and data3.yaml file of:</p>
|
||||||
|
<pre><code class="yaml">b: [2, 3, 4]
|
||||||
|
c:
|
||||||
|
test: 2
|
||||||
|
other: true
|
||||||
|
d: false
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<p>then</p>
|
||||||
|
<pre><code class="bash">yq m -x data1.yaml data3.yaml
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<p>will output:</p>
|
||||||
|
<pre><code class="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>
|
||||||
|
<h3 id="multiple-documents-merge-into-single-document">Multiple Documents - merge into single document<a class="headerlink" href="#multiple-documents-merge-into-single-document" title="Permanent link">¶</a></h3>
|
||||||
|
<p>Currently yq only has multi-document support for the <em>first</em> document being merged into. The remaining yaml files will have their first document selected.</p>
|
||||||
|
<p>Given a data1.yaml file of:</p>
|
||||||
|
<pre><code class="yaml">something: else
|
||||||
|
---
|
||||||
|
a: simple
|
||||||
|
b: cat
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<p>and data3.yaml file of:</p>
|
||||||
|
<pre><code class="yaml">b: dog
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<p>then</p>
|
||||||
|
<pre><code class="bash">yq m -x -d1 data1.yaml data3.yaml
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<p>will output:</p>
|
||||||
|
<pre><code class="yaml">something: else
|
||||||
|
---
|
||||||
|
a: simple
|
||||||
|
b: dog
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<h3 id="multiple-documents-merge-into-all-documents">Multiple Documents - merge into all documents<a class="headerlink" href="#multiple-documents-merge-into-all-documents" title="Permanent link">¶</a></h3>
|
||||||
|
<p>Currently yq only has multi-document support for the <em>first</em> document being merged into. The remaining yaml files will have their first document selected.</p>
|
||||||
|
<p>Given a data1.yaml file of:</p>
|
||||||
|
<pre><code class="yaml">something: else
|
||||||
|
---
|
||||||
|
a: simple
|
||||||
|
b: cat
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<p>and data3.yaml file of:</p>
|
||||||
|
<pre><code class="yaml">b: dog
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<p>then</p>
|
||||||
|
<pre><code class="bash">yq m -x -d'*' data1.yaml data3.yaml
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<p>will output:</p>
|
||||||
|
<pre><code class="yaml">b: dog
|
||||||
|
something: else
|
||||||
|
---
|
||||||
|
a: simple
|
||||||
|
b: dog
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</article>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
|
||||||
|
|
||||||
|
<footer class="md-footer">
|
||||||
|
|
||||||
|
<div class="md-footer-nav">
|
||||||
|
<nav class="md-footer-nav__inner md-grid">
|
||||||
|
|
||||||
|
<a href="../convert/" title="Convert" class="md-flex md-footer-nav__link md-footer-nav__link--prev" rel="prev">
|
||||||
|
<div class="md-flex__cell md-flex__cell--shrink">
|
||||||
|
<i class="md-icon md-icon--arrow-back md-footer-nav__button"></i>
|
||||||
|
</div>
|
||||||
|
<div class="md-flex__cell md-flex__cell--stretch md-footer-nav__title">
|
||||||
|
<span class="md-flex__ellipsis">
|
||||||
|
<span class="md-footer-nav__direction">
|
||||||
|
Previous
|
||||||
|
</span>
|
||||||
|
Convert
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
|
||||||
|
</nav>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="md-footer-meta md-typeset">
|
||||||
|
<div class="md-footer-meta__inner md-grid">
|
||||||
|
<div class="md-footer-copyright">
|
||||||
|
|
||||||
|
powered by
|
||||||
|
<a href="http://www.mkdocs.org">MkDocs</a>
|
||||||
|
and
|
||||||
|
<a href="https://squidfunk.github.io/mkdocs-material/">
|
||||||
|
Material for MkDocs</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="md-footer-social">
|
||||||
|
|
||||||
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
|
||||||
|
|
||||||
|
<a href="https://github.com/mikefarah" class="md-footer-social__link fa fa-github"></a>
|
||||||
|
|
||||||
|
<a href="https://www.linkedin.com/in/mike-farah-b5a75b2/" class="md-footer-social__link fa fa-linkedin"></a>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</footer>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script src="../assets/javascripts/application.6cdc17f0.js"></script>
|
||||||
|
|
||||||
|
<script>app.initialize({version:"0.17.2",url:{base:".."}})</script>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
636
docs/read/index.html
Normal file
636
docs/read/index.html
Normal file
@@ -0,0 +1,636 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en" class="no-js">
|
||||||
|
<head>
|
||||||
|
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||||
|
<meta http-equiv="x-ua-compatible" content="ie=edge">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<meta name="lang:clipboard.copy" content="Copy to clipboard">
|
||||||
|
|
||||||
|
<meta name="lang:clipboard.copied" content="Copied to clipboard">
|
||||||
|
|
||||||
|
<meta name="lang:search.language" content="en">
|
||||||
|
|
||||||
|
<meta name="lang:search.result.none" content="No matching documents">
|
||||||
|
|
||||||
|
<meta name="lang:search.result.one" content="1 matching document">
|
||||||
|
|
||||||
|
<meta name="lang:search.result.other" content="# matching documents">
|
||||||
|
|
||||||
|
<meta name="lang:search.tokenizer" content="[\s\-]+">
|
||||||
|
|
||||||
|
<link rel="shortcut icon" href="../assets/images/favicon.png">
|
||||||
|
<meta name="generator" content="mkdocs-0.17.2, mkdocs-material-2.2.5">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<title>Read - Yq</title>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<link rel="stylesheet" href="../assets/stylesheets/application.bcabdff3.css">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<script src="../assets/javascripts/modernizr.1aa3b519.js"></script>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,400i,700|Roboto+Mono">
|
||||||
|
<style>body,input{font-family:"Roboto","Helvetica Neue",Helvetica,Arial,sans-serif}code,kbd,pre{font-family:"Roboto Mono","Courier New",Courier,monospace}</style>
|
||||||
|
|
||||||
|
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<svg class="md-svg">
|
||||||
|
<defs>
|
||||||
|
|
||||||
|
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="416" height="448" viewBox="0 0 416 448" id="github"><path fill="currentColor" d="M160 304q0 10-3.125 20.5t-10.75 19T128 352t-18.125-8.5-10.75-19T96 304t3.125-20.5 10.75-19T128 256t18.125 8.5 10.75 19T160 304zm160 0q0 10-3.125 20.5t-10.75 19T288 352t-18.125-8.5-10.75-19T256 304t3.125-20.5 10.75-19T288 256t18.125 8.5 10.75 19T320 304zm40 0q0-30-17.25-51T296 232q-10.25 0-48.75 5.25Q229.5 240 208 240t-39.25-2.75Q130.75 232 120 232q-29.5 0-46.75 21T56 304q0 22 8 38.375t20.25 25.75 30.5 15 35 7.375 37.25 1.75h42q20.5 0 37.25-1.75t35-7.375 30.5-15 20.25-25.75T360 304zm56-44q0 51.75-15.25 82.75-9.5 19.25-26.375 33.25t-35.25 21.5-42.5 11.875-42.875 5.5T212 416q-19.5 0-35.5-.75t-36.875-3.125-38.125-7.5-34.25-12.875T37 371.5t-21.5-28.75Q0 312 0 260q0-59.25 34-99-6.75-20.5-6.75-42.5 0-29 12.75-54.5 27 0 47.5 9.875t47.25 30.875Q171.5 96 212 96q37 0 70 8 26.25-20.5 46.75-30.25T376 64q12.75 25.5 12.75 54.5 0 21.75-6.75 42 34 40 34 99.5z"/></svg>
|
||||||
|
|
||||||
|
</defs>
|
||||||
|
</svg>
|
||||||
|
<input class="md-toggle" data-md-toggle="drawer" type="checkbox" id="drawer">
|
||||||
|
<input class="md-toggle" data-md-toggle="search" type="checkbox" id="search">
|
||||||
|
<label class="md-overlay" data-md-component="overlay" for="drawer"></label>
|
||||||
|
|
||||||
|
<header class="md-header" data-md-component="header">
|
||||||
|
<nav class="md-header-nav md-grid">
|
||||||
|
<div class="md-flex">
|
||||||
|
<div class="md-flex__cell md-flex__cell--shrink">
|
||||||
|
<a href=".." title="Yq" class="md-header-nav__button md-logo">
|
||||||
|
|
||||||
|
<i class="md-icon"></i>
|
||||||
|
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<div class="md-flex__cell md-flex__cell--shrink">
|
||||||
|
<label class="md-icon md-icon--menu md-header-nav__button" for="drawer"></label>
|
||||||
|
</div>
|
||||||
|
<div class="md-flex__cell md-flex__cell--stretch">
|
||||||
|
<div class="md-flex__ellipsis md-header-nav__title" data-md-component="title">
|
||||||
|
|
||||||
|
|
||||||
|
<span class="md-header-nav__topic">
|
||||||
|
Yq
|
||||||
|
</span>
|
||||||
|
<span class="md-header-nav__topic">
|
||||||
|
Read
|
||||||
|
</span>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="md-flex__cell md-flex__cell--shrink">
|
||||||
|
|
||||||
|
|
||||||
|
<label class="md-icon md-icon--search md-header-nav__button" for="search"></label>
|
||||||
|
|
||||||
|
<div class="md-search" data-md-component="search" role="dialog">
|
||||||
|
<label class="md-search__overlay" for="search"></label>
|
||||||
|
<div class="md-search__inner">
|
||||||
|
<form class="md-search__form" name="search">
|
||||||
|
<input type="text" class="md-search__input" name="query" required placeholder="Search" autocapitalize="off" autocorrect="off" autocomplete="off" spellcheck="false" data-md-component="query">
|
||||||
|
<label class="md-icon md-search__icon" for="search"></label>
|
||||||
|
<button type="reset" class="md-icon md-search__icon" data-md-component="reset"></button>
|
||||||
|
</form>
|
||||||
|
<div class="md-search__output">
|
||||||
|
<div class="md-search__scrollwrap" data-md-scrollfix>
|
||||||
|
<div class="md-search-result" data-md-component="result">
|
||||||
|
<div class="md-search-result__meta">
|
||||||
|
Type to start searching
|
||||||
|
</div>
|
||||||
|
<ol class="md-search-result__list"></ol>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="md-flex__cell md-flex__cell--shrink">
|
||||||
|
<div class="md-header-nav__source">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<a href="https://github.com/mikefarah/yq/" title="Go to repository" class="md-source" data-md-source="github">
|
||||||
|
|
||||||
|
<div class="md-source__icon">
|
||||||
|
<svg viewBox="0 0 24 24" width="24" height="24">
|
||||||
|
<use xlink:href="#github" width="24" height="24"></use>
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="md-source__repository">
|
||||||
|
mikefarah/yq
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<div class="md-container">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<main class="md-main">
|
||||||
|
<div class="md-main__inner md-grid" data-md-component="container">
|
||||||
|
|
||||||
|
|
||||||
|
<div class="md-sidebar md-sidebar--primary" data-md-component="navigation">
|
||||||
|
<div class="md-sidebar__scrollwrap">
|
||||||
|
<div class="md-sidebar__inner">
|
||||||
|
<nav class="md-nav md-nav--primary" data-md-level="0">
|
||||||
|
<label class="md-nav__title md-nav__title--site" for="drawer">
|
||||||
|
<span class="md-nav__button md-logo">
|
||||||
|
|
||||||
|
<i class="md-icon"></i>
|
||||||
|
|
||||||
|
</span>
|
||||||
|
Yq
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<div class="md-nav__source">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<a href="https://github.com/mikefarah/yq/" title="Go to repository" class="md-source" data-md-source="github">
|
||||||
|
|
||||||
|
<div class="md-source__icon">
|
||||||
|
<svg viewBox="0 0 24 24" width="24" height="24">
|
||||||
|
<use xlink:href="#github" width="24" height="24"></use>
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="md-source__repository">
|
||||||
|
mikefarah/yq
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<ul class="md-nav__list" data-md-scrollfix>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href=".." title="Install" class="md-nav__link">
|
||||||
|
Install
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<li class="md-nav__item md-nav__item--active">
|
||||||
|
|
||||||
|
<input class="md-toggle md-nav__toggle" data-md-toggle="toc" type="checkbox" id="toc">
|
||||||
|
|
||||||
|
|
||||||
|
<label class="md-nav__link md-nav__link--active" for="toc">
|
||||||
|
Read
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<a href="./" title="Read" class="md-nav__link md-nav__link--active">
|
||||||
|
Read
|
||||||
|
</a>
|
||||||
|
|
||||||
|
|
||||||
|
<nav class="md-nav md-nav--secondary">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<label class="md-nav__title" for="toc">Table of contents</label>
|
||||||
|
<ul class="md-nav__list" data-md-scrollfix>
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="#basic" title="Basic" class="md-nav__link">
|
||||||
|
Basic
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="#from-stdin" title="From Stdin" class="md-nav__link">
|
||||||
|
From Stdin
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="#splat" title="Splat" class="md-nav__link">
|
||||||
|
Splat
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="#multiple-documents" title="Multiple Documents" class="md-nav__link">
|
||||||
|
Multiple Documents
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="#arrays" title="Arrays" class="md-nav__link">
|
||||||
|
Arrays
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="#array-splat" title="Array Splat" class="md-nav__link">
|
||||||
|
Array Splat
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="#keys-with-dots" title="Keys with dots" class="md-nav__link">
|
||||||
|
Keys with dots
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="../write/" title="Write/Update" class="md-nav__link">
|
||||||
|
Write/Update
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="../delete/" title="Delete" class="md-nav__link">
|
||||||
|
Delete
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="../create/" title="Create" class="md-nav__link">
|
||||||
|
Create
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="../convert/" title="Convert" class="md-nav__link">
|
||||||
|
Convert
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="../merge/" title="Merge" class="md-nav__link">
|
||||||
|
Merge
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
|
||||||
|
</ul>
|
||||||
|
</nav>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="md-sidebar md-sidebar--secondary" data-md-component="toc">
|
||||||
|
<div class="md-sidebar__scrollwrap">
|
||||||
|
<div class="md-sidebar__inner">
|
||||||
|
|
||||||
|
<nav class="md-nav md-nav--secondary">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<label class="md-nav__title" for="toc">Table of contents</label>
|
||||||
|
<ul class="md-nav__list" data-md-scrollfix>
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="#basic" title="Basic" class="md-nav__link">
|
||||||
|
Basic
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="#from-stdin" title="From Stdin" class="md-nav__link">
|
||||||
|
From Stdin
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="#splat" title="Splat" class="md-nav__link">
|
||||||
|
Splat
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="#multiple-documents" title="Multiple Documents" class="md-nav__link">
|
||||||
|
Multiple Documents
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="#arrays" title="Arrays" class="md-nav__link">
|
||||||
|
Arrays
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="#array-splat" title="Array Splat" class="md-nav__link">
|
||||||
|
Array Splat
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="#keys-with-dots" title="Keys with dots" class="md-nav__link">
|
||||||
|
Keys with dots
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
</nav>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="md-content">
|
||||||
|
<article class="md-content__inner md-typeset">
|
||||||
|
|
||||||
|
|
||||||
|
<a href="https://github.com/mikefarah/yq/edit/master/docs/read.md" title="Edit this page" class="md-icon md-content__icon"></a>
|
||||||
|
|
||||||
|
|
||||||
|
<h1>Read</h1>
|
||||||
|
|
||||||
|
<pre><code>yq r <yaml_file|json_file> <path>
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<p>This command can take a json file as input too, and will output yaml unless specified to export as json (-j)</p>
|
||||||
|
<h3 id="basic">Basic<a class="headerlink" href="#basic" title="Permanent link">¶</a></h3>
|
||||||
|
<p>Given a sample.yaml file of:</p>
|
||||||
|
<pre><code class="yaml">b:
|
||||||
|
c: 2
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<p>then</p>
|
||||||
|
<pre><code class="bash">yq r sample.yaml b.c
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<p>will output the value of '2'.</p>
|
||||||
|
<h3 id="from-stdin">From Stdin<a class="headerlink" href="#from-stdin" title="Permanent link">¶</a></h3>
|
||||||
|
<p>Given a sample.yaml file of:</p>
|
||||||
|
<pre><code class="bash">cat sample.yaml | yq r - b.c
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<p>will output the value of '2'.</p>
|
||||||
|
<h3 id="splat">Splat<a class="headerlink" href="#splat" title="Permanent link">¶</a></h3>
|
||||||
|
<p>Given a sample.yaml file of:</p>
|
||||||
|
<pre><code class="yaml">---
|
||||||
|
bob:
|
||||||
|
item1:
|
||||||
|
cats: bananas
|
||||||
|
item2:
|
||||||
|
cats: apples
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<p>then</p>
|
||||||
|
<pre><code class="bash">yq r sample.yaml bob.*.cats
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<p>will output</p>
|
||||||
|
<pre><code class="yaml">- bananas
|
||||||
|
- apples
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<h3 id="multiple-documents">Multiple Documents<a class="headerlink" href="#multiple-documents" title="Permanent link">¶</a></h3>
|
||||||
|
<p>Given a sample.yaml file of:</p>
|
||||||
|
<pre><code class="yaml">something: else
|
||||||
|
---
|
||||||
|
b:
|
||||||
|
c: 2
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<p>then</p>
|
||||||
|
<pre><code class="bash">yq r -d1 sample.yaml b.c
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<p>will output the value of '2'.</p>
|
||||||
|
<h3 id="arrays">Arrays<a class="headerlink" href="#arrays" title="Permanent link">¶</a></h3>
|
||||||
|
<p>You can give an index to access a specific element:
|
||||||
|
e.g.: given a sample file of</p>
|
||||||
|
<pre><code class="yaml">b:
|
||||||
|
e:
|
||||||
|
- name: fred
|
||||||
|
value: 3
|
||||||
|
- name: sam
|
||||||
|
value: 4
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<p>then</p>
|
||||||
|
<pre><code>yq r sample.yaml 'b.e[1].name'
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<p>will output 'sam'</p>
|
||||||
|
<p>Note that the path is in quotes to avoid the square brackets being interpreted by your shell.</p>
|
||||||
|
<h3 id="array-splat">Array Splat<a class="headerlink" href="#array-splat" title="Permanent link">¶</a></h3>
|
||||||
|
<p>e.g.: given a sample file of</p>
|
||||||
|
<pre><code class="yaml">b:
|
||||||
|
e:
|
||||||
|
- name: fred
|
||||||
|
value: 3
|
||||||
|
- name: sam
|
||||||
|
value: 4
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<p>then</p>
|
||||||
|
<pre><code>yq r sample.yaml 'b.e[*].name'
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<p>will output:</p>
|
||||||
|
<pre><code>- fred
|
||||||
|
- sam
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<p>Note that the path is in quotes to avoid the square brackets being interpreted by your shell.</p>
|
||||||
|
<h3 id="keys-with-dots">Keys with dots<a class="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><code class="yaml">b:
|
||||||
|
foo.bar: 7
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<pre><code class="bash">yaml r sample.yaml 'b[foo.bar]'
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<pre><code class="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>
|
||||||
|
<p>Note that the path is in quotes to avoid the square brackets being interpreted by your shell.</p>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</article>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
|
||||||
|
|
||||||
|
<footer class="md-footer">
|
||||||
|
|
||||||
|
<div class="md-footer-nav">
|
||||||
|
<nav class="md-footer-nav__inner md-grid">
|
||||||
|
|
||||||
|
<a href=".." title="Install" class="md-flex md-footer-nav__link md-footer-nav__link--prev" rel="prev">
|
||||||
|
<div class="md-flex__cell md-flex__cell--shrink">
|
||||||
|
<i class="md-icon md-icon--arrow-back md-footer-nav__button"></i>
|
||||||
|
</div>
|
||||||
|
<div class="md-flex__cell md-flex__cell--stretch md-footer-nav__title">
|
||||||
|
<span class="md-flex__ellipsis">
|
||||||
|
<span class="md-footer-nav__direction">
|
||||||
|
Previous
|
||||||
|
</span>
|
||||||
|
Install
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
|
||||||
|
<a href="../write/" title="Write/Update" class="md-flex md-footer-nav__link md-footer-nav__link--next" rel="next">
|
||||||
|
<div class="md-flex__cell md-flex__cell--stretch md-footer-nav__title">
|
||||||
|
<span class="md-flex__ellipsis">
|
||||||
|
<span class="md-footer-nav__direction">
|
||||||
|
Next
|
||||||
|
</span>
|
||||||
|
Write/Update
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div class="md-flex__cell md-flex__cell--shrink">
|
||||||
|
<i class="md-icon md-icon--arrow-forward md-footer-nav__button"></i>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</nav>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="md-footer-meta md-typeset">
|
||||||
|
<div class="md-footer-meta__inner md-grid">
|
||||||
|
<div class="md-footer-copyright">
|
||||||
|
|
||||||
|
powered by
|
||||||
|
<a href="http://www.mkdocs.org">MkDocs</a>
|
||||||
|
and
|
||||||
|
<a href="https://squidfunk.github.io/mkdocs-material/">
|
||||||
|
Material for MkDocs</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="md-footer-social">
|
||||||
|
|
||||||
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
|
||||||
|
|
||||||
|
<a href="https://github.com/mikefarah" class="md-footer-social__link fa fa-github"></a>
|
||||||
|
|
||||||
|
<a href="https://www.linkedin.com/in/mike-farah-b5a75b2/" class="md-footer-social__link fa fa-linkedin"></a>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</footer>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script src="../assets/javascripts/application.6cdc17f0.js"></script>
|
||||||
|
|
||||||
|
<script>app.initialize({version:"0.17.2",url:{base:".."}})</script>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
224
docs/search/search_index.json
Normal file
224
docs/search/search_index.json
Normal file
@@ -0,0 +1,224 @@
|
|||||||
|
{
|
||||||
|
"docs": [
|
||||||
|
{
|
||||||
|
"location": "/",
|
||||||
|
"text": "yq\n\u00b6\n\n\nyq 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\nInstall\n\u00b6\n\n\nOn MacOS:\n\n\nbrew install yq\n\n\n\n\nOn Ubuntu and other Linux distros supporting \nsnap\n packages:\n\n\nsnap install yq\n\n\n\n\nOn Ubuntu 16.04 or higher from Debian package:\n\n\nsudo add-apt-repository ppa:rmescandon/yq\nsudo apt update\nsudo apt install yq -y\n\n\n\n\nor, \nDownload latest binary\n or alternatively:\n\n\ngo get gopkg.in/mikefarah/yq.v2\n\n\n\n\nView on GitHub",
|
||||||
|
"title": "Install"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"location": "/#yq",
|
||||||
|
"text": "yq 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": "yq"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"location": "/#install",
|
||||||
|
"text": "On MacOS: brew install yq On Ubuntu and other Linux distros supporting snap packages: snap install yq On Ubuntu 16.04 or higher from Debian package: sudo add-apt-repository ppa:rmescandon/yq\nsudo apt update\nsudo apt install yq -y or, Download latest binary or alternatively: go get gopkg.in/mikefarah/yq.v2 View on GitHub",
|
||||||
|
"title": "Install"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"location": "/read/",
|
||||||
|
"text": "yq r <yaml_file|json_file> <path>\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\u00b6\n\n\nGiven a sample.yaml file of:\n\n\nb:\n c: 2\n\n\n\n\nthen\n\n\nyq r sample.yaml b.c\n\n\n\n\nwill output the value of '2'.\n\n\nFrom Stdin\n\u00b6\n\n\nGiven a sample.yaml file of:\n\n\ncat sample.yaml | yq r - b.c\n\n\n\n\nwill output the value of '2'.\n\n\nSplat\n\u00b6\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\nyq r sample.yaml bob.*.cats\n\n\n\n\nwill output\n\n\n- bananas\n- apples\n\n\n\n\nMultiple Documents\n\u00b6\n\n\nGiven a sample.yaml file of:\n\n\nsomething: else\n---\nb:\n c: 2\n\n\n\n\nthen\n\n\nyq r -d1 sample.yaml b.c\n\n\n\n\nwill output the value of '2'.\n\n\nArrays\n\u00b6\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\nyq r sample.yaml 'b.e[1].name'\n\n\n\n\nwill output 'sam'\n\n\nNote that the path is in quotes to avoid the square brackets being interpreted by your shell.\n\n\nArray Splat\n\u00b6\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\nyq r sample.yaml 'b.e[*].name'\n\n\n\n\nwill output:\n\n\n- fred\n- sam\n\n\n\n\nNote that the path is in quotes to avoid the square brackets being interpreted by your shell.\n\n\nKeys with dots\n\u00b6\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.\n\n\nNote that the path is in quotes to avoid the square brackets being interpreted by your shell.",
|
||||||
|
"title": "Read"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"location": "/read/#basic",
|
||||||
|
"text": "Given a sample.yaml file of: b:\n c: 2 then yq 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 | yq 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 yq r sample.yaml bob.*.cats will output - bananas\n- apples",
|
||||||
|
"title": "Splat"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"location": "/read/#multiple-documents",
|
||||||
|
"text": "Given a sample.yaml file of: something: else\n---\nb:\n c: 2 then yq r -d1 sample.yaml b.c will output the value of '2'.",
|
||||||
|
"title": "Multiple Documents"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"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 yq r sample.yaml 'b.e[1].name' will output 'sam' Note that the path is in quotes to avoid the square brackets being interpreted by your shell.",
|
||||||
|
"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 yq r sample.yaml 'b.e[*].name' will output: - fred\n- sam Note that the path is in quotes to avoid the square brackets being interpreted by your shell.",
|
||||||
|
"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. Note that the path is in quotes to avoid the square brackets being interpreted by your shell.",
|
||||||
|
"title": "Keys with dots"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"location": "/write/",
|
||||||
|
"text": "yq w <yaml_file> <path> <new value>\n\n\n\n\nTo Stdout\n\u00b6\n\n\nGiven a sample.yaml file of:\n\n\nb:\n c: 2\n\n\n\n\nthen\n\n\nyq 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\u00b6\n\n\ncat sample.yaml | yq w - b.c blah\n\n\n\n\nAdding new fields\n\u00b6\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\nyq w sample.yaml b.d[0] \"new thing\"\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\u00b6\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\nyq w sample.yaml \"b.d[+]\" \"bar thing\"\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\nNote that the path is in quotes to avoid the square brackets being interpreted by your shell.\n\n\nMultiple Documents - update a single document\n\u00b6\n\n\nGiven a sample.yaml file of:\n\n\nsomething: else\n---\nb:\n c: 2\n\n\n\n\nthen\n\n\nyq w -d1 sample.yaml b.c 5\n\n\n\n\nwill output:\n\n\nsomething: else\n---\nb:\n c: 5\n\n\n\n\nMultiple Documents - update all documents\n\u00b6\n\n\nGiven a sample.yaml file of:\n\n\nsomething: else\n---\nb:\n c: 2\n\n\n\n\nthen\n\n\nyq w -d'*' sample.yaml b.c 5\n\n\n\n\nwill output:\n\n\nsomething: else\nb:\n c: 5\n---\nb:\n c: 5\n\n\n\n\nNote that '*' is in quotes to avoid being interpreted by your shell.\n\n\nUpdating files in-place\n\u00b6\n\n\nGiven a sample.yaml file of:\n\n\nb:\n c: 2\n\n\n\n\nthen\n\n\nyq 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\u00b6\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\nyq 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 | yq w -s - sample.yaml\n\n\n\n\nValues starting with a hyphen (or dash)\n\u00b6\n\n\nThe flag terminator needs to be used to stop the app from attempting to parse the subsequent arguments as flags:\n\n\nyq w -- my.path -3\n\n\n\n\nwill output\n\n\nmy:\n path: -3\n\n\n\n\nKeys with dots\n\u00b6\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.\n\n\nNote that the path is in quotes to avoid the square brackets being interpreted by your shell.",
|
||||||
|
"title": "Write/Update"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"location": "/write/#to-stdout",
|
||||||
|
"text": "Given a sample.yaml file of: b:\n c: 2 then yq w sample.yaml b.c cat will output: b:\n c: cat",
|
||||||
|
"title": "To Stdout"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"location": "/write/#from-stdin",
|
||||||
|
"text": "cat sample.yaml | yq 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 yq w sample.yaml b.d[0] \"new thing\" will output: b:\n c: cat\n d:\n - new thing",
|
||||||
|
"title": "Adding new fields"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"location": "/write/#appending-value-to-an-array-field",
|
||||||
|
"text": "Given a sample.yaml file of: b:\n c: 2\n d:\n - new thing\n - foo thing then yq w sample.yaml \"b.d[+]\" \"bar thing\" will output: b:\n c: cat\n d:\n - new thing\n - foo thing\n - bar thing Note that the path is in quotes to avoid the square brackets being interpreted by your shell.",
|
||||||
|
"title": "Appending value to an array field"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"location": "/write/#multiple-documents-update-a-single-document",
|
||||||
|
"text": "Given a sample.yaml file of: something: else\n---\nb:\n c: 2 then yq w -d1 sample.yaml b.c 5 will output: something: else\n---\nb:\n c: 5",
|
||||||
|
"title": "Multiple Documents - update a single document"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"location": "/write/#multiple-documents-update-all-documents",
|
||||||
|
"text": "Given a sample.yaml file of: something: else\n---\nb:\n c: 2 then yq w -d'*' sample.yaml b.c 5 will output: something: else\nb:\n c: 5\n---\nb:\n c: 5 Note that '*' is in quotes to avoid being interpreted by your shell.",
|
||||||
|
"title": "Multiple Documents - update all documents"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"location": "/write/#updating-files-in-place",
|
||||||
|
"text": "Given a sample.yaml file of: b:\n c: 2 then yq w -i sample.yaml b.c cat will update the sample.yaml file so that the value of 'c' is cat.",
|
||||||
|
"title": "Updating files in-place"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"location": "/write/#updating-multiple-values-with-a-script",
|
||||||
|
"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 yq 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 | yq w -s - sample.yaml",
|
||||||
|
"title": "Updating multiple values with a script"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"location": "/write/#values-starting-with-a-hyphen-or-dash",
|
||||||
|
"text": "The flag terminator needs to be used to stop the app from attempting to parse the subsequent arguments as flags: yq 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. Note that the path is in quotes to avoid the square brackets being interpreted by your shell.",
|
||||||
|
"title": "Keys with dots"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"location": "/delete/",
|
||||||
|
"text": "yq d <yaml_file> <path_to_delete>\n\n\n\n\nTo Stdout\n\u00b6\n\n\nGiven a sample.yaml file of:\n\n\nb:\n c: 2\n apples: green\n\n\n\n\nthen\n\n\nyq d sample.yaml b.c\n\n\n\n\nwill output:\n\n\nb:\n apples: green\n\n\n\n\nFrom STDIN\n\u00b6\n\n\ncat sample.yaml | yq d - b.c\n\n\n\n\nDeleting array elements\n\u00b6\n\n\nGiven a sample.yaml file of:\n\n\nb:\n c: \n - 1\n - 2\n - 3\n\n\n\n\nthen\n\n\nyq d sample.yaml 'b.c[1]'\n\n\n\n\nwill output:\n\n\nb:\n c:\n - 1\n - 3\n\n\n\n\nDeleting nodes in-place\n\u00b6\n\n\nGiven a sample.yaml file of:\n\n\nb:\n c: 2\n apples: green\n\n\n\n\nthen\n\n\nyq d -i sample.yaml b.c\n\n\n\n\nwill update the sample.yaml file so that the 'c' node is deleted\n\n\nMultiple Documents - delete from single document\n\u00b6\n\n\nGiven a sample.yaml file of:\n\n\nsomething: else\nfield: leaveMe\n---\nb:\n c: 2\nfield: deleteMe\n\n\n\n\nthen\n\n\nyq w -d1 sample.yaml field\n\n\n\n\nwill output:\n\n\nsomething: else\nfield: leaveMe\n---\nb:\n c: 2\n\n\n\n\nMultiple Documents - delete from all documents\n\u00b6\n\n\nGiven a sample.yaml file of:\n\n\nsomething: else\nfield: deleteMe\n---\nb:\n c: 2\nfield: deleteMeToo\n\n\n\n\nthen\n\n\nyq w -d'*' sample.yaml field\n\n\n\n\nwill output:\n\n\nsomething: else\n---\nb:\n c: 2\n\n\n\n\nNote that '*' is in quotes to avoid being interpreted by your shell.\n\n\nKeys with dots\n\u00b6\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.\n\n\nNote that the path is in quotes to avoid the square brackets being interpreted by your shell.",
|
||||||
|
"title": "Delete"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"location": "/delete/#to-stdout",
|
||||||
|
"text": "Given a sample.yaml file of: b:\n c: 2\n apples: green then yq d sample.yaml b.c will output: b:\n apples: green",
|
||||||
|
"title": "To Stdout"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"location": "/delete/#from-stdin",
|
||||||
|
"text": "cat sample.yaml | yq d - b.c",
|
||||||
|
"title": "From STDIN"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"location": "/delete/#deleting-array-elements",
|
||||||
|
"text": "Given a sample.yaml file of: b:\n c: \n - 1\n - 2\n - 3 then yq d sample.yaml 'b.c[1]' will output: b:\n c:\n - 1\n - 3",
|
||||||
|
"title": "Deleting array elements"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"location": "/delete/#deleting-nodes-in-place",
|
||||||
|
"text": "Given a sample.yaml file of: b:\n c: 2\n apples: green then yq d -i sample.yaml b.c will update the sample.yaml file so that the 'c' node is deleted",
|
||||||
|
"title": "Deleting nodes in-place"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"location": "/delete/#multiple-documents-delete-from-single-document",
|
||||||
|
"text": "Given a sample.yaml file of: something: else\nfield: leaveMe\n---\nb:\n c: 2\nfield: deleteMe then yq w -d1 sample.yaml field will output: something: else\nfield: leaveMe\n---\nb:\n c: 2",
|
||||||
|
"title": "Multiple Documents - delete from single document"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"location": "/delete/#multiple-documents-delete-from-all-documents",
|
||||||
|
"text": "Given a sample.yaml file of: something: else\nfield: deleteMe\n---\nb:\n c: 2\nfield: deleteMeToo then yq w -d'*' sample.yaml field will output: something: else\n---\nb:\n c: 2 Note that '*' is in quotes to avoid being interpreted by your shell.",
|
||||||
|
"title": "Multiple Documents - delete from all documents"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"location": "/delete/#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. Note that the path is in quotes to avoid the square brackets being interpreted by your shell.",
|
||||||
|
"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. Currently this does not support creating multiple documents in a single yaml file.\n\n\nyq n <path> <new value>\n\n\n\n\nCreating a simple yaml file\n\u00b6\n\n\nyq 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\u00b6\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\nyq 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 | yq n -s -\n\n\n\n\nKeys with dots\n\u00b6\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.\n\n\nNote that the path is in quotes to avoid the square brackets being interpreted by your shell.",
|
||||||
|
"title": "Create"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"location": "/create/#creating-a-simple-yaml-file",
|
||||||
|
"text": "yq n b.c cat will output: b:\n c: cat",
|
||||||
|
"title": "Creating a simple yaml file"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"location": "/create/#creating-using-a-create-script",
|
||||||
|
"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 yq 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 | yq 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. Note that the path is in quotes to avoid the square brackets being interpreted by your shell.",
|
||||||
|
"title": "Keys with dots"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"location": "/convert/",
|
||||||
|
"text": "Yaml to Json\n\u00b6\n\n\nTo convert output to json, use the --tojson (or -j) flag. This can only be used with the read command.\n\n\nGiven a sample.yaml file of:\n\n\nb:\n c: 2\n\n\n\n\nthen\n\n\nyq r -j sample.yaml b.c\n\n\n\n\nwill output\n\n\n{\"b\":{\"c\":2}}\n\n\n\n\nJson to Yaml\n\u00b6\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{\"a\":\"Easy! as one two three\",\"b\":{\"c\":2,\"d\":[3,4]}}\n\n\n\n\nthen\n\n\nyq 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 only be used with the read command. Given a sample.yaml file of: b:\n c: 2 then yq 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 yq 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\nyq m <yaml_file> <path>...\n\n\n\n\nTo Stdout\n\u00b6\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\nyq 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\u00b6\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\nyq 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\u00b6\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\nyq 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\u00b6\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\nyq 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.\n\n\nMultiple Documents - merge into single document\n\u00b6\n\n\nCurrently yq only has multi-document support for the \nfirst\n document being merged into. The remaining yaml files will have their first document selected.\n\n\nGiven a data1.yaml file of:\n\n\nsomething: else\n---\na: simple\nb: cat\n\n\n\n\nand data3.yaml file of:\n\n\nb: dog\n\n\n\n\nthen\n\n\nyq m -x -d1 data1.yaml data3.yaml\n\n\n\n\nwill output:\n\n\nsomething: else\n---\na: simple\nb: dog\n\n\n\n\nMultiple Documents - merge into all documents\n\u00b6\n\n\nCurrently yq only has multi-document support for the \nfirst\n document being merged into. The remaining yaml files will have their first document selected.\n\n\nGiven a data1.yaml file of:\n\n\nsomething: else\n---\na: simple\nb: cat\n\n\n\n\nand data3.yaml file of:\n\n\nb: dog\n\n\n\n\nthen\n\n\nyq m -x -d'*' data1.yaml data3.yaml\n\n\n\n\nwill output:\n\n\nb: dog\nsomething: else\n---\na: simple\nb: dog",
|
||||||
|
"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 yq 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 yq 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 yq m -x data1.yaml data2.yaml will output: a: other\nb: [1, 2]\nc:\n test: 1",
|
||||||
|
"title": "Overwrite values"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"location": "/merge/#overwrite-values-with-arrays",
|
||||||
|
"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 yq 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.",
|
||||||
|
"title": "Overwrite values with arrays"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"location": "/merge/#multiple-documents-merge-into-single-document",
|
||||||
|
"text": "Currently yq only has multi-document support for the first document being merged into. The remaining yaml files will have their first document selected. Given a data1.yaml file of: something: else\n---\na: simple\nb: cat and data3.yaml file of: b: dog then yq m -x -d1 data1.yaml data3.yaml will output: something: else\n---\na: simple\nb: dog",
|
||||||
|
"title": "Multiple Documents - merge into single document"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"location": "/merge/#multiple-documents-merge-into-all-documents",
|
||||||
|
"text": "Currently yq only has multi-document support for the first document being merged into. The remaining yaml files will have their first document selected. Given a data1.yaml file of: something: else\n---\na: simple\nb: cat and data3.yaml file of: b: dog then yq m -x -d'*' data1.yaml data3.yaml will output: b: dog\nsomething: else\n---\na: simple\nb: dog",
|
||||||
|
"title": "Multiple Documents - merge into all documents"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
60
docs/sitemap.xml
Normal file
60
docs/sitemap.xml
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
||||||
|
|
||||||
|
|
||||||
|
<url>
|
||||||
|
<loc>/</loc>
|
||||||
|
<lastmod>2018-06-20</lastmod>
|
||||||
|
<changefreq>daily</changefreq>
|
||||||
|
</url>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<url>
|
||||||
|
<loc>/read/</loc>
|
||||||
|
<lastmod>2018-06-20</lastmod>
|
||||||
|
<changefreq>daily</changefreq>
|
||||||
|
</url>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<url>
|
||||||
|
<loc>/write/</loc>
|
||||||
|
<lastmod>2018-06-20</lastmod>
|
||||||
|
<changefreq>daily</changefreq>
|
||||||
|
</url>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<url>
|
||||||
|
<loc>/delete/</loc>
|
||||||
|
<lastmod>2018-06-20</lastmod>
|
||||||
|
<changefreq>daily</changefreq>
|
||||||
|
</url>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<url>
|
||||||
|
<loc>/create/</loc>
|
||||||
|
<lastmod>2018-06-20</lastmod>
|
||||||
|
<changefreq>daily</changefreq>
|
||||||
|
</url>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<url>
|
||||||
|
<loc>/convert/</loc>
|
||||||
|
<lastmod>2018-06-20</lastmod>
|
||||||
|
<changefreq>daily</changefreq>
|
||||||
|
</url>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<url>
|
||||||
|
<loc>/merge/</loc>
|
||||||
|
<lastmod>2018-06-20</lastmod>
|
||||||
|
<changefreq>daily</changefreq>
|
||||||
|
</url>
|
||||||
|
|
||||||
|
|
||||||
|
</urlset>
|
||||||
741
docs/write/index.html
Normal file
741
docs/write/index.html
Normal file
@@ -0,0 +1,741 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en" class="no-js">
|
||||||
|
<head>
|
||||||
|
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||||
|
<meta http-equiv="x-ua-compatible" content="ie=edge">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<meta name="lang:clipboard.copy" content="Copy to clipboard">
|
||||||
|
|
||||||
|
<meta name="lang:clipboard.copied" content="Copied to clipboard">
|
||||||
|
|
||||||
|
<meta name="lang:search.language" content="en">
|
||||||
|
|
||||||
|
<meta name="lang:search.result.none" content="No matching documents">
|
||||||
|
|
||||||
|
<meta name="lang:search.result.one" content="1 matching document">
|
||||||
|
|
||||||
|
<meta name="lang:search.result.other" content="# matching documents">
|
||||||
|
|
||||||
|
<meta name="lang:search.tokenizer" content="[\s\-]+">
|
||||||
|
|
||||||
|
<link rel="shortcut icon" href="../assets/images/favicon.png">
|
||||||
|
<meta name="generator" content="mkdocs-0.17.2, mkdocs-material-2.2.5">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<title>Write/Update - Yq</title>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<link rel="stylesheet" href="../assets/stylesheets/application.bcabdff3.css">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<script src="../assets/javascripts/modernizr.1aa3b519.js"></script>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,400i,700|Roboto+Mono">
|
||||||
|
<style>body,input{font-family:"Roboto","Helvetica Neue",Helvetica,Arial,sans-serif}code,kbd,pre{font-family:"Roboto Mono","Courier New",Courier,monospace}</style>
|
||||||
|
|
||||||
|
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<svg class="md-svg">
|
||||||
|
<defs>
|
||||||
|
|
||||||
|
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="416" height="448" viewBox="0 0 416 448" id="github"><path fill="currentColor" d="M160 304q0 10-3.125 20.5t-10.75 19T128 352t-18.125-8.5-10.75-19T96 304t3.125-20.5 10.75-19T128 256t18.125 8.5 10.75 19T160 304zm160 0q0 10-3.125 20.5t-10.75 19T288 352t-18.125-8.5-10.75-19T256 304t3.125-20.5 10.75-19T288 256t18.125 8.5 10.75 19T320 304zm40 0q0-30-17.25-51T296 232q-10.25 0-48.75 5.25Q229.5 240 208 240t-39.25-2.75Q130.75 232 120 232q-29.5 0-46.75 21T56 304q0 22 8 38.375t20.25 25.75 30.5 15 35 7.375 37.25 1.75h42q20.5 0 37.25-1.75t35-7.375 30.5-15 20.25-25.75T360 304zm56-44q0 51.75-15.25 82.75-9.5 19.25-26.375 33.25t-35.25 21.5-42.5 11.875-42.875 5.5T212 416q-19.5 0-35.5-.75t-36.875-3.125-38.125-7.5-34.25-12.875T37 371.5t-21.5-28.75Q0 312 0 260q0-59.25 34-99-6.75-20.5-6.75-42.5 0-29 12.75-54.5 27 0 47.5 9.875t47.25 30.875Q171.5 96 212 96q37 0 70 8 26.25-20.5 46.75-30.25T376 64q12.75 25.5 12.75 54.5 0 21.75-6.75 42 34 40 34 99.5z"/></svg>
|
||||||
|
|
||||||
|
</defs>
|
||||||
|
</svg>
|
||||||
|
<input class="md-toggle" data-md-toggle="drawer" type="checkbox" id="drawer">
|
||||||
|
<input class="md-toggle" data-md-toggle="search" type="checkbox" id="search">
|
||||||
|
<label class="md-overlay" data-md-component="overlay" for="drawer"></label>
|
||||||
|
|
||||||
|
<header class="md-header" data-md-component="header">
|
||||||
|
<nav class="md-header-nav md-grid">
|
||||||
|
<div class="md-flex">
|
||||||
|
<div class="md-flex__cell md-flex__cell--shrink">
|
||||||
|
<a href=".." title="Yq" class="md-header-nav__button md-logo">
|
||||||
|
|
||||||
|
<i class="md-icon"></i>
|
||||||
|
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<div class="md-flex__cell md-flex__cell--shrink">
|
||||||
|
<label class="md-icon md-icon--menu md-header-nav__button" for="drawer"></label>
|
||||||
|
</div>
|
||||||
|
<div class="md-flex__cell md-flex__cell--stretch">
|
||||||
|
<div class="md-flex__ellipsis md-header-nav__title" data-md-component="title">
|
||||||
|
|
||||||
|
|
||||||
|
<span class="md-header-nav__topic">
|
||||||
|
Yq
|
||||||
|
</span>
|
||||||
|
<span class="md-header-nav__topic">
|
||||||
|
Write/Update
|
||||||
|
</span>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="md-flex__cell md-flex__cell--shrink">
|
||||||
|
|
||||||
|
|
||||||
|
<label class="md-icon md-icon--search md-header-nav__button" for="search"></label>
|
||||||
|
|
||||||
|
<div class="md-search" data-md-component="search" role="dialog">
|
||||||
|
<label class="md-search__overlay" for="search"></label>
|
||||||
|
<div class="md-search__inner">
|
||||||
|
<form class="md-search__form" name="search">
|
||||||
|
<input type="text" class="md-search__input" name="query" required placeholder="Search" autocapitalize="off" autocorrect="off" autocomplete="off" spellcheck="false" data-md-component="query">
|
||||||
|
<label class="md-icon md-search__icon" for="search"></label>
|
||||||
|
<button type="reset" class="md-icon md-search__icon" data-md-component="reset"></button>
|
||||||
|
</form>
|
||||||
|
<div class="md-search__output">
|
||||||
|
<div class="md-search__scrollwrap" data-md-scrollfix>
|
||||||
|
<div class="md-search-result" data-md-component="result">
|
||||||
|
<div class="md-search-result__meta">
|
||||||
|
Type to start searching
|
||||||
|
</div>
|
||||||
|
<ol class="md-search-result__list"></ol>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="md-flex__cell md-flex__cell--shrink">
|
||||||
|
<div class="md-header-nav__source">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<a href="https://github.com/mikefarah/yq/" title="Go to repository" class="md-source" data-md-source="github">
|
||||||
|
|
||||||
|
<div class="md-source__icon">
|
||||||
|
<svg viewBox="0 0 24 24" width="24" height="24">
|
||||||
|
<use xlink:href="#github" width="24" height="24"></use>
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="md-source__repository">
|
||||||
|
mikefarah/yq
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<div class="md-container">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<main class="md-main">
|
||||||
|
<div class="md-main__inner md-grid" data-md-component="container">
|
||||||
|
|
||||||
|
|
||||||
|
<div class="md-sidebar md-sidebar--primary" data-md-component="navigation">
|
||||||
|
<div class="md-sidebar__scrollwrap">
|
||||||
|
<div class="md-sidebar__inner">
|
||||||
|
<nav class="md-nav md-nav--primary" data-md-level="0">
|
||||||
|
<label class="md-nav__title md-nav__title--site" for="drawer">
|
||||||
|
<span class="md-nav__button md-logo">
|
||||||
|
|
||||||
|
<i class="md-icon"></i>
|
||||||
|
|
||||||
|
</span>
|
||||||
|
Yq
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<div class="md-nav__source">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<a href="https://github.com/mikefarah/yq/" title="Go to repository" class="md-source" data-md-source="github">
|
||||||
|
|
||||||
|
<div class="md-source__icon">
|
||||||
|
<svg viewBox="0 0 24 24" width="24" height="24">
|
||||||
|
<use xlink:href="#github" width="24" height="24"></use>
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="md-source__repository">
|
||||||
|
mikefarah/yq
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<ul class="md-nav__list" data-md-scrollfix>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href=".." title="Install" class="md-nav__link">
|
||||||
|
Install
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="../read/" title="Read" class="md-nav__link">
|
||||||
|
Read
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<li class="md-nav__item md-nav__item--active">
|
||||||
|
|
||||||
|
<input class="md-toggle md-nav__toggle" data-md-toggle="toc" type="checkbox" id="toc">
|
||||||
|
|
||||||
|
|
||||||
|
<label class="md-nav__link md-nav__link--active" for="toc">
|
||||||
|
Write/Update
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<a href="./" title="Write/Update" class="md-nav__link md-nav__link--active">
|
||||||
|
Write/Update
|
||||||
|
</a>
|
||||||
|
|
||||||
|
|
||||||
|
<nav class="md-nav md-nav--secondary">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<label class="md-nav__title" for="toc">Table of contents</label>
|
||||||
|
<ul class="md-nav__list" data-md-scrollfix>
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="#to-stdout" title="To Stdout" class="md-nav__link">
|
||||||
|
To Stdout
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="#from-stdin" title="From STDIN" class="md-nav__link">
|
||||||
|
From STDIN
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="#adding-new-fields" title="Adding new fields" class="md-nav__link">
|
||||||
|
Adding new fields
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="#appending-value-to-an-array-field" title="Appending value to an array field" class="md-nav__link">
|
||||||
|
Appending value to an array field
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="#multiple-documents-update-a-single-document" title="Multiple Documents - update a single document" class="md-nav__link">
|
||||||
|
Multiple Documents - update a single document
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="#multiple-documents-update-all-documents" title="Multiple Documents - update all documents" class="md-nav__link">
|
||||||
|
Multiple Documents - update all documents
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="#updating-files-in-place" title="Updating files in-place" class="md-nav__link">
|
||||||
|
Updating files in-place
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="#updating-multiple-values-with-a-script" title="Updating multiple values with a script" class="md-nav__link">
|
||||||
|
Updating multiple values with a script
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="#values-starting-with-a-hyphen-or-dash" title="Values starting with a hyphen (or dash)" class="md-nav__link">
|
||||||
|
Values starting with a hyphen (or dash)
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="#keys-with-dots" title="Keys with dots" class="md-nav__link">
|
||||||
|
Keys with dots
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="../delete/" title="Delete" class="md-nav__link">
|
||||||
|
Delete
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="../create/" title="Create" class="md-nav__link">
|
||||||
|
Create
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="../convert/" title="Convert" class="md-nav__link">
|
||||||
|
Convert
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="../merge/" title="Merge" class="md-nav__link">
|
||||||
|
Merge
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
|
||||||
|
</ul>
|
||||||
|
</nav>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="md-sidebar md-sidebar--secondary" data-md-component="toc">
|
||||||
|
<div class="md-sidebar__scrollwrap">
|
||||||
|
<div class="md-sidebar__inner">
|
||||||
|
|
||||||
|
<nav class="md-nav md-nav--secondary">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<label class="md-nav__title" for="toc">Table of contents</label>
|
||||||
|
<ul class="md-nav__list" data-md-scrollfix>
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="#to-stdout" title="To Stdout" class="md-nav__link">
|
||||||
|
To Stdout
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="#from-stdin" title="From STDIN" class="md-nav__link">
|
||||||
|
From STDIN
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="#adding-new-fields" title="Adding new fields" class="md-nav__link">
|
||||||
|
Adding new fields
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="#appending-value-to-an-array-field" title="Appending value to an array field" class="md-nav__link">
|
||||||
|
Appending value to an array field
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="#multiple-documents-update-a-single-document" title="Multiple Documents - update a single document" class="md-nav__link">
|
||||||
|
Multiple Documents - update a single document
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="#multiple-documents-update-all-documents" title="Multiple Documents - update all documents" class="md-nav__link">
|
||||||
|
Multiple Documents - update all documents
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="#updating-files-in-place" title="Updating files in-place" class="md-nav__link">
|
||||||
|
Updating files in-place
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="#updating-multiple-values-with-a-script" title="Updating multiple values with a script" class="md-nav__link">
|
||||||
|
Updating multiple values with a script
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="#values-starting-with-a-hyphen-or-dash" title="Values starting with a hyphen (or dash)" class="md-nav__link">
|
||||||
|
Values starting with a hyphen (or dash)
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="#keys-with-dots" title="Keys with dots" class="md-nav__link">
|
||||||
|
Keys with dots
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
</nav>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="md-content">
|
||||||
|
<article class="md-content__inner md-typeset">
|
||||||
|
|
||||||
|
|
||||||
|
<a href="https://github.com/mikefarah/yq/edit/master/docs/write.md" title="Edit this page" class="md-icon md-content__icon"></a>
|
||||||
|
|
||||||
|
|
||||||
|
<h1>Write/Update</h1>
|
||||||
|
|
||||||
|
<pre><code>yq w <yaml_file> <path> <new value>
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<h3 id="to-stdout">To Stdout<a class="headerlink" href="#to-stdout" title="Permanent link">¶</a></h3>
|
||||||
|
<p>Given a sample.yaml file of:</p>
|
||||||
|
<pre><code class="yaml">b:
|
||||||
|
c: 2
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<p>then</p>
|
||||||
|
<pre><code class="bash">yq w sample.yaml b.c cat
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<p>will output:</p>
|
||||||
|
<pre><code class="yaml">b:
|
||||||
|
c: cat
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<h3 id="from-stdin">From STDIN<a class="headerlink" href="#from-stdin" title="Permanent link">¶</a></h3>
|
||||||
|
<pre><code class="bash">cat sample.yaml | yq w - b.c blah
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<h3 id="adding-new-fields">Adding new fields<a class="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><code class="yaml">b:
|
||||||
|
c: 2
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<p>then</p>
|
||||||
|
<pre><code class="bash">yq w sample.yaml b.d[0] "new thing"
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<p>will output:</p>
|
||||||
|
<pre><code class="yaml">b:
|
||||||
|
c: cat
|
||||||
|
d:
|
||||||
|
- new thing
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<h3 id="appending-value-to-an-array-field">Appending value to an array field<a class="headerlink" href="#appending-value-to-an-array-field" title="Permanent link">¶</a></h3>
|
||||||
|
<p>Given a sample.yaml file of:</p>
|
||||||
|
<pre><code class="yaml">b:
|
||||||
|
c: 2
|
||||||
|
d:
|
||||||
|
- new thing
|
||||||
|
- foo thing
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<p>then</p>
|
||||||
|
<pre><code class="bash">yq w sample.yaml "b.d[+]" "bar thing"
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<p>will output:</p>
|
||||||
|
<pre><code class="yaml">b:
|
||||||
|
c: cat
|
||||||
|
d:
|
||||||
|
- new thing
|
||||||
|
- foo thing
|
||||||
|
- bar thing
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<p>Note that the path is in quotes to avoid the square brackets being interpreted by your shell.</p>
|
||||||
|
<h3 id="multiple-documents-update-a-single-document">Multiple Documents - update a single document<a class="headerlink" href="#multiple-documents-update-a-single-document" title="Permanent link">¶</a></h3>
|
||||||
|
<p>Given a sample.yaml file of:</p>
|
||||||
|
<pre><code class="yaml">something: else
|
||||||
|
---
|
||||||
|
b:
|
||||||
|
c: 2
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<p>then</p>
|
||||||
|
<pre><code class="bash">yq w -d1 sample.yaml b.c 5
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<p>will output:</p>
|
||||||
|
<pre><code class="yaml">something: else
|
||||||
|
---
|
||||||
|
b:
|
||||||
|
c: 5
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<h3 id="multiple-documents-update-all-documents">Multiple Documents - update all documents<a class="headerlink" href="#multiple-documents-update-all-documents" title="Permanent link">¶</a></h3>
|
||||||
|
<p>Given a sample.yaml file of:</p>
|
||||||
|
<pre><code class="yaml">something: else
|
||||||
|
---
|
||||||
|
b:
|
||||||
|
c: 2
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<p>then</p>
|
||||||
|
<pre><code class="bash">yq w -d'*' sample.yaml b.c 5
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<p>will output:</p>
|
||||||
|
<pre><code class="yaml">something: else
|
||||||
|
b:
|
||||||
|
c: 5
|
||||||
|
---
|
||||||
|
b:
|
||||||
|
c: 5
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<p>Note that '*' is in quotes to avoid being interpreted by your shell.</p>
|
||||||
|
<h3 id="updating-files-in-place">Updating files in-place<a class="headerlink" href="#updating-files-in-place" title="Permanent link">¶</a></h3>
|
||||||
|
<p>Given a sample.yaml file of:</p>
|
||||||
|
<pre><code class="yaml">b:
|
||||||
|
c: 2
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<p>then</p>
|
||||||
|
<pre><code class="bash">yq 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>
|
||||||
|
<h3 id="updating-multiple-values-with-a-script">Updating multiple values with a script<a class="headerlink" href="#updating-multiple-values-with-a-script" title="Permanent link">¶</a></h3>
|
||||||
|
<p>Given a sample.yaml file of:</p>
|
||||||
|
<pre><code class="yaml">b:
|
||||||
|
c: 2
|
||||||
|
e:
|
||||||
|
- name: Billy Bob
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<p>and a script update_instructions.yaml of:</p>
|
||||||
|
<pre><code class="yaml">b.c: 3
|
||||||
|
b.e[0].name: Howdy Partner
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<p>then</p>
|
||||||
|
<pre><code class="bash">yq w -s update_instructions.yaml sample.yaml
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<p>will output:</p>
|
||||||
|
<pre><code class="yaml">b:
|
||||||
|
c: 3
|
||||||
|
e:
|
||||||
|
- name: Howdy Partner
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<p>And, of course, you can pipe the instructions in using '-':</p>
|
||||||
|
<pre><code class="bash">cat update_instructions.yaml | yq w -s - sample.yaml
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<h3 id="values-starting-with-a-hyphen-or-dash">Values starting with a hyphen (or dash)<a class="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>yq w -- my.path -3
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<p>will output</p>
|
||||||
|
<pre><code class="yaml">my:
|
||||||
|
path: -3
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<h3 id="keys-with-dots">Keys with dots<a class="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><code class="yaml">b:
|
||||||
|
foo.bar: 7
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<pre><code class="bash">yaml r sample.yaml 'b[foo.bar]'
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<pre><code class="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>
|
||||||
|
<p>Note that the path is in quotes to avoid the square brackets being interpreted by your shell.</p>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</article>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
|
||||||
|
|
||||||
|
<footer class="md-footer">
|
||||||
|
|
||||||
|
<div class="md-footer-nav">
|
||||||
|
<nav class="md-footer-nav__inner md-grid">
|
||||||
|
|
||||||
|
<a href="../read/" title="Read" class="md-flex md-footer-nav__link md-footer-nav__link--prev" rel="prev">
|
||||||
|
<div class="md-flex__cell md-flex__cell--shrink">
|
||||||
|
<i class="md-icon md-icon--arrow-back md-footer-nav__button"></i>
|
||||||
|
</div>
|
||||||
|
<div class="md-flex__cell md-flex__cell--stretch md-footer-nav__title">
|
||||||
|
<span class="md-flex__ellipsis">
|
||||||
|
<span class="md-footer-nav__direction">
|
||||||
|
Previous
|
||||||
|
</span>
|
||||||
|
Read
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
|
||||||
|
<a href="../delete/" title="Delete" class="md-flex md-footer-nav__link md-footer-nav__link--next" rel="next">
|
||||||
|
<div class="md-flex__cell md-flex__cell--stretch md-footer-nav__title">
|
||||||
|
<span class="md-flex__ellipsis">
|
||||||
|
<span class="md-footer-nav__direction">
|
||||||
|
Next
|
||||||
|
</span>
|
||||||
|
Delete
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div class="md-flex__cell md-flex__cell--shrink">
|
||||||
|
<i class="md-icon md-icon--arrow-forward md-footer-nav__button"></i>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</nav>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="md-footer-meta md-typeset">
|
||||||
|
<div class="md-footer-meta__inner md-grid">
|
||||||
|
<div class="md-footer-copyright">
|
||||||
|
|
||||||
|
powered by
|
||||||
|
<a href="http://www.mkdocs.org">MkDocs</a>
|
||||||
|
and
|
||||||
|
<a href="https://squidfunk.github.io/mkdocs-material/">
|
||||||
|
Material for MkDocs</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="md-footer-social">
|
||||||
|
|
||||||
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
|
||||||
|
|
||||||
|
<a href="https://github.com/mikefarah" class="md-footer-social__link fa fa-github"></a>
|
||||||
|
|
||||||
|
<a href="https://www.linkedin.com/in/mike-farah-b5a75b2/" class="md-footer-social__link fa fa-linkedin"></a>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</footer>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script src="../assets/javascripts/application.6cdc17f0.js"></script>
|
||||||
|
|
||||||
|
<script>app.initialize({version:"0.17.2",url:{base:".."}})</script>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
9
examples/array.yaml
Normal file
9
examples/array.yaml
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
---
|
||||||
|
- become: true
|
||||||
|
gather_facts: false
|
||||||
|
hosts: lalaland
|
||||||
|
name: "Apply smth"
|
||||||
|
roles:
|
||||||
|
- lala
|
||||||
|
- land
|
||||||
|
serial: 1
|
||||||
2
examples/data1.yaml
Normal file
2
examples/data1.yaml
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
a: simple
|
||||||
|
b: [1, 2]
|
||||||
4
examples/data2.yaml
Normal file
4
examples/data2.yaml
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
a: other
|
||||||
|
b: [3, 4]
|
||||||
|
c:
|
||||||
|
test: 1
|
||||||
1
examples/data3.yaml
Normal file
1
examples/data3.yaml
Normal file
@@ -0,0 +1 @@
|
|||||||
|
b: dog
|
||||||
5
examples/multiline-text.yaml
Normal file
5
examples/multiline-text.yaml
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
test: |
|
||||||
|
abcdefg
|
||||||
|
hijklmno
|
||||||
|
|
||||||
|
|
||||||
18
examples/multiple_docs.yaml
Normal file
18
examples/multiple_docs.yaml
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
commonKey: first document
|
||||||
|
a: Easy! as one two three
|
||||||
|
b:
|
||||||
|
c: 2
|
||||||
|
d: [3, 4]
|
||||||
|
e:
|
||||||
|
- name: fred
|
||||||
|
value: 3
|
||||||
|
- name: sam
|
||||||
|
value: 4
|
||||||
|
---
|
||||||
|
commonKey: second document
|
||||||
|
another:
|
||||||
|
document: here
|
||||||
|
---
|
||||||
|
commonKey: third document
|
||||||
|
wow:
|
||||||
|
- here is another
|
||||||
7
examples/multiple_docs_small.yaml
Normal file
7
examples/multiple_docs_small.yaml
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
a: Easy! as one two three
|
||||||
|
---
|
||||||
|
another:
|
||||||
|
document: here
|
||||||
|
---
|
||||||
|
- 1
|
||||||
|
- 2
|
||||||
2
examples/order.yaml
Normal file
2
examples/order.yaml
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
version: 3
|
||||||
|
application: MyApp
|
||||||
6
examples/order.yml
Normal file
6
examples/order.yml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
version: '2'
|
||||||
|
services:
|
||||||
|
test:
|
||||||
|
image: ubuntu:14.04
|
||||||
|
stdin_open: true
|
||||||
|
tty: true
|
||||||
1
examples/sample.json
Normal file
1
examples/sample.json
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{"a":"Easy! as one two three","b":{"c":2,"d":[3,4],"e":[{"name":"fred","value":3},{"name":"sam","value":4}]}}
|
||||||
@@ -6,4 +6,4 @@ b:
|
|||||||
- name: fred
|
- name: fred
|
||||||
value: 3
|
value: 3
|
||||||
- name: sam
|
- name: sam
|
||||||
value: 4
|
value: 4
|
||||||
1
examples/sample_array.yaml
Normal file
1
examples/sample_array.yaml
Normal file
@@ -0,0 +1 @@
|
|||||||
|
[1,2,3]
|
||||||
1
examples/sample_array_2.yaml
Normal file
1
examples/sample_array_2.yaml
Normal file
@@ -0,0 +1 @@
|
|||||||
|
[4,5]
|
||||||
1
examples/sample_text.yaml
Normal file
1
examples/sample_text.yaml
Normal file
@@ -0,0 +1 @@
|
|||||||
|
hi
|
||||||
44
json_converter.go
Normal file
44
json_converter.go
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
yaml "gopkg.in/mikefarah/yaml.v2"
|
||||||
|
)
|
||||||
|
|
||||||
|
func jsonToString(context interface{}) (string, error) {
|
||||||
|
out, err := json.Marshal(toJSON(context))
|
||||||
|
if err != nil {
|
||||||
|
return "", fmt.Errorf("error printing yaml as json: %v", err)
|
||||||
|
}
|
||||||
|
return string(out), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func toJSON(context interface{}) interface{} {
|
||||||
|
switch context.(type) {
|
||||||
|
case []interface{}:
|
||||||
|
oldArray := context.([]interface{})
|
||||||
|
newArray := make([]interface{}, len(oldArray))
|
||||||
|
for index, value := range oldArray {
|
||||||
|
newArray[index] = toJSON(value)
|
||||||
|
}
|
||||||
|
return newArray
|
||||||
|
case yaml.MapSlice:
|
||||||
|
oldMap := context.(yaml.MapSlice)
|
||||||
|
newMap := make(map[string]interface{})
|
||||||
|
for _, entry := range oldMap {
|
||||||
|
if str, ok := entry.Key.(string); ok {
|
||||||
|
newMap[str] = toJSON(entry.Value)
|
||||||
|
} else if i, ok := entry.Key.(int); ok {
|
||||||
|
newMap[strconv.Itoa(i)] = toJSON(entry.Value)
|
||||||
|
} else if b, ok := entry.Key.(bool); ok {
|
||||||
|
newMap[strconv.FormatBool(b)] = toJSON(entry.Value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return newMap
|
||||||
|
default:
|
||||||
|
return context
|
||||||
|
}
|
||||||
|
}
|
||||||
46
json_converter_test.go
Normal file
46
json_converter_test.go
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestJsonToString(t *testing.T) {
|
||||||
|
var data = parseData(`
|
||||||
|
---
|
||||||
|
b:
|
||||||
|
c: 2
|
||||||
|
`)
|
||||||
|
got, _ := jsonToString(data)
|
||||||
|
assertResult(t, "{\"b\":{\"c\":2}}", got)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestJsonToString_withIntKey(t *testing.T) {
|
||||||
|
var data = parseData(`
|
||||||
|
---
|
||||||
|
b:
|
||||||
|
2: c
|
||||||
|
`)
|
||||||
|
got, _ := jsonToString(data)
|
||||||
|
assertResult(t, `{"b":{"2":"c"}}`, got)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestJsonToString_withBoolKey(t *testing.T) {
|
||||||
|
var data = parseData(`
|
||||||
|
---
|
||||||
|
b:
|
||||||
|
false: c
|
||||||
|
`)
|
||||||
|
got, _ := jsonToString(data)
|
||||||
|
assertResult(t, `{"b":{"false":"c"}}`, got)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestJsonToString_withArray(t *testing.T) {
|
||||||
|
var data = parseData(`
|
||||||
|
---
|
||||||
|
b:
|
||||||
|
- item: one
|
||||||
|
- item: two
|
||||||
|
`)
|
||||||
|
got, _ := jsonToString(data)
|
||||||
|
assertResult(t, "{\"b\":[{\"item\":\"one\"},{\"item\":\"two\"}]}", got)
|
||||||
|
}
|
||||||
12
merge.go
Normal file
12
merge.go
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import "gopkg.in/imdario/mergo.v0"
|
||||||
|
|
||||||
|
func merge(dst interface{}, src interface{}, overwrite bool, append bool) error {
|
||||||
|
if overwrite {
|
||||||
|
return mergo.Merge(dst, src, mergo.WithOverride)
|
||||||
|
} else if append {
|
||||||
|
return mergo.Merge(dst, src, mergo.WithAppendSlice)
|
||||||
|
}
|
||||||
|
return mergo.Merge(dst, src)
|
||||||
|
}
|
||||||
26
mkdocs.yml
Normal file
26
mkdocs.yml
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
docs_dir: mkdocs
|
||||||
|
site_dir: docs
|
||||||
|
site_name: Yq
|
||||||
|
theme: 'material'
|
||||||
|
pages:
|
||||||
|
- Install: index.md
|
||||||
|
- Read: read.md
|
||||||
|
- Write/Update: write.md
|
||||||
|
- Delete: delete.md
|
||||||
|
- Create: create.md
|
||||||
|
- Convert: convert.md
|
||||||
|
- Merge: merge.md
|
||||||
|
repo_name: 'mikefarah/yq'
|
||||||
|
repo_url: 'https://github.com/mikefarah/yq'
|
||||||
|
|
||||||
|
extra:
|
||||||
|
social:
|
||||||
|
- type: 'github'
|
||||||
|
link: 'https://github.com/mikefarah'
|
||||||
|
- type: 'linkedin'
|
||||||
|
link: 'https://www.linkedin.com/in/mike-farah-b5a75b2/'
|
||||||
|
|
||||||
|
markdown_extensions:
|
||||||
|
- markdown_include.include:
|
||||||
|
base_path: mkdocs
|
||||||
|
- toc(permalink=true)
|
||||||
40
mkdocs/convert.md
Normal file
40
mkdocs/convert.md
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
### Yaml to Json
|
||||||
|
To convert output to json, use the --tojson (or -j) flag. This can only be used with the read command.
|
||||||
|
|
||||||
|
Given a sample.yaml file of:
|
||||||
|
```yaml
|
||||||
|
b:
|
||||||
|
c: 2
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq r -j sample.yaml b.c
|
||||||
|
```
|
||||||
|
|
||||||
|
will output
|
||||||
|
```json
|
||||||
|
{"b":{"c":2}}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Json to Yaml
|
||||||
|
To read in json, just pass in a json file instead of yaml, it will just work :)
|
||||||
|
|
||||||
|
e.g given a json file
|
||||||
|
|
||||||
|
```json
|
||||||
|
{"a":"Easy! as one two three","b":{"c":2,"d":[3,4]}}
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq r sample.json
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
a: Easy! as one two three
|
||||||
|
b:
|
||||||
|
c: 2
|
||||||
|
d:
|
||||||
|
- 3
|
||||||
|
- 4
|
||||||
|
```
|
||||||
|
|
||||||
44
mkdocs/create.md
Normal file
44
mkdocs/create.md
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
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. Currently this does not support creating multiple documents in a single yaml file.
|
||||||
|
|
||||||
|
```
|
||||||
|
yq n <path> <new value>
|
||||||
|
```
|
||||||
|
|
||||||
|
### Creating a simple yaml file
|
||||||
|
```bash
|
||||||
|
yq n b.c cat
|
||||||
|
```
|
||||||
|
will output:
|
||||||
|
```yaml
|
||||||
|
b:
|
||||||
|
c: cat
|
||||||
|
```
|
||||||
|
|
||||||
|
### Creating using a create script
|
||||||
|
Create scripts follow the same format as the update scripts.
|
||||||
|
|
||||||
|
Given a script create_instructions.yaml of:
|
||||||
|
```yaml
|
||||||
|
b.c: 3
|
||||||
|
b.e[0].name: Howdy Partner
|
||||||
|
```
|
||||||
|
then
|
||||||
|
|
||||||
|
```bash
|
||||||
|
yq n -s create_instructions.yaml
|
||||||
|
```
|
||||||
|
will output:
|
||||||
|
```yaml
|
||||||
|
b:
|
||||||
|
c: 3
|
||||||
|
e:
|
||||||
|
- name: Howdy Partner
|
||||||
|
```
|
||||||
|
|
||||||
|
You can also pipe the instructions in:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cat create_instructions.yaml | yq n -s -
|
||||||
|
```
|
||||||
|
|
||||||
|
{!snippets/keys_with_dots.md!}
|
||||||
110
mkdocs/delete.md
Normal file
110
mkdocs/delete.md
Normal file
@@ -0,0 +1,110 @@
|
|||||||
|
```
|
||||||
|
yq d <yaml_file> <path_to_delete>
|
||||||
|
```
|
||||||
|
|
||||||
|
### To Stdout
|
||||||
|
Given a sample.yaml file of:
|
||||||
|
```yaml
|
||||||
|
b:
|
||||||
|
c: 2
|
||||||
|
apples: green
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq d sample.yaml b.c
|
||||||
|
```
|
||||||
|
will output:
|
||||||
|
```yaml
|
||||||
|
b:
|
||||||
|
apples: green
|
||||||
|
```
|
||||||
|
|
||||||
|
### From STDIN
|
||||||
|
```bash
|
||||||
|
cat sample.yaml | yq d - b.c
|
||||||
|
```
|
||||||
|
|
||||||
|
### Deleting array elements
|
||||||
|
Given a sample.yaml file of:
|
||||||
|
```yaml
|
||||||
|
b:
|
||||||
|
c:
|
||||||
|
- 1
|
||||||
|
- 2
|
||||||
|
- 3
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq d sample.yaml 'b.c[1]'
|
||||||
|
```
|
||||||
|
will output:
|
||||||
|
```yaml
|
||||||
|
b:
|
||||||
|
c:
|
||||||
|
- 1
|
||||||
|
- 3
|
||||||
|
```
|
||||||
|
|
||||||
|
### Deleting nodes in-place
|
||||||
|
Given a sample.yaml file of:
|
||||||
|
```yaml
|
||||||
|
b:
|
||||||
|
c: 2
|
||||||
|
apples: green
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq d -i sample.yaml b.c
|
||||||
|
```
|
||||||
|
will update the sample.yaml file so that the 'c' node is deleted
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### Multiple Documents - delete from single document
|
||||||
|
Given a sample.yaml file of:
|
||||||
|
```yaml
|
||||||
|
something: else
|
||||||
|
field: leaveMe
|
||||||
|
---
|
||||||
|
b:
|
||||||
|
c: 2
|
||||||
|
field: deleteMe
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq w -d1 sample.yaml field
|
||||||
|
```
|
||||||
|
will output:
|
||||||
|
```yaml
|
||||||
|
something: else
|
||||||
|
field: leaveMe
|
||||||
|
---
|
||||||
|
b:
|
||||||
|
c: 2
|
||||||
|
```
|
||||||
|
|
||||||
|
### Multiple Documents - delete from all documents
|
||||||
|
Given a sample.yaml file of:
|
||||||
|
```yaml
|
||||||
|
something: else
|
||||||
|
field: deleteMe
|
||||||
|
---
|
||||||
|
b:
|
||||||
|
c: 2
|
||||||
|
field: deleteMeToo
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq w -d'*' sample.yaml field
|
||||||
|
```
|
||||||
|
will output:
|
||||||
|
```yaml
|
||||||
|
something: else
|
||||||
|
---
|
||||||
|
b:
|
||||||
|
c: 2
|
||||||
|
```
|
||||||
|
|
||||||
|
Note that '*' is in quotes to avoid being interpreted by your shell.
|
||||||
|
|
||||||
|
{!snippets/keys_with_dots.md!}
|
||||||
26
mkdocs/index.md
Normal file
26
mkdocs/index.md
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
# 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.
|
||||||
|
|
||||||
|
## Install
|
||||||
|
On MacOS:
|
||||||
|
```
|
||||||
|
brew install yq
|
||||||
|
```
|
||||||
|
On Ubuntu and other Linux distros supporting `snap` packages:
|
||||||
|
```
|
||||||
|
snap install yq
|
||||||
|
```
|
||||||
|
On Ubuntu 16.04 or higher from Debian package:
|
||||||
|
```
|
||||||
|
sudo add-apt-repository ppa:rmescandon/yq
|
||||||
|
sudo apt update
|
||||||
|
sudo apt install yq -y
|
||||||
|
```
|
||||||
|
or, [Download latest binary](https://github.com/mikefarah/yq/releases/latest) or alternatively:
|
||||||
|
```
|
||||||
|
go get gopkg.in/mikefarah/yq.v2
|
||||||
|
```
|
||||||
|
|
||||||
|
[View on GitHub](https://github.com/mikefarah/yq)
|
||||||
157
mkdocs/merge.md
Normal file
157
mkdocs/merge.md
Normal file
@@ -0,0 +1,157 @@
|
|||||||
|
Yaml files can be merged using the 'merge' command. Each additional file merged with the first file will
|
||||||
|
set values for any key not existing already or where the key has no value.
|
||||||
|
|
||||||
|
```
|
||||||
|
yq m <yaml_file> <path>...
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
### To Stdout
|
||||||
|
Given a data1.yaml file of:
|
||||||
|
```yaml
|
||||||
|
a: simple
|
||||||
|
b: [1, 2]
|
||||||
|
```
|
||||||
|
and data2.yaml file of:
|
||||||
|
```yaml
|
||||||
|
a: other
|
||||||
|
c:
|
||||||
|
test: 1
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq m data1.yaml data2.yaml
|
||||||
|
```
|
||||||
|
will output:
|
||||||
|
```yaml
|
||||||
|
a: simple
|
||||||
|
b: [1, 2]
|
||||||
|
c:
|
||||||
|
test: 1
|
||||||
|
```
|
||||||
|
|
||||||
|
### Updating files in-place
|
||||||
|
Given a data1.yaml file of:
|
||||||
|
```yaml
|
||||||
|
a: simple
|
||||||
|
b: [1, 2]
|
||||||
|
```
|
||||||
|
and data2.yaml file of:
|
||||||
|
```yaml
|
||||||
|
a: other
|
||||||
|
c:
|
||||||
|
test: 1
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq m -i data1.yaml data2.yaml
|
||||||
|
```
|
||||||
|
will update the data1.yaml file so that the value of 'c' is 'test: 1'.
|
||||||
|
|
||||||
|
### Overwrite values
|
||||||
|
Given a data1.yaml file of:
|
||||||
|
```yaml
|
||||||
|
a: simple
|
||||||
|
b: [1, 2]
|
||||||
|
```
|
||||||
|
and data2.yaml file of:
|
||||||
|
```yaml
|
||||||
|
a: other
|
||||||
|
c:
|
||||||
|
test: 1
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq m -x data1.yaml data2.yaml
|
||||||
|
```
|
||||||
|
will output:
|
||||||
|
```yaml
|
||||||
|
a: other
|
||||||
|
b: [1, 2]
|
||||||
|
c:
|
||||||
|
test: 1
|
||||||
|
```
|
||||||
|
|
||||||
|
### Overwrite values with arrays
|
||||||
|
Given a data1.yaml file of:
|
||||||
|
```yaml
|
||||||
|
a: simple
|
||||||
|
b: [1, 2]
|
||||||
|
```
|
||||||
|
and data3.yaml file of:
|
||||||
|
```yaml
|
||||||
|
b: [2, 3, 4]
|
||||||
|
c:
|
||||||
|
test: 2
|
||||||
|
other: true
|
||||||
|
d: false
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq m -x data1.yaml data3.yaml
|
||||||
|
```
|
||||||
|
will output:
|
||||||
|
```yaml
|
||||||
|
a: simple
|
||||||
|
b: [2, 3, 4]
|
||||||
|
c:
|
||||||
|
test: 2
|
||||||
|
other: true
|
||||||
|
d: false
|
||||||
|
```
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
### Multiple Documents - merge into single document
|
||||||
|
Currently yq only has multi-document support for the _first_ document being merged into. The remaining yaml files will have their first document selected.
|
||||||
|
|
||||||
|
Given a data1.yaml file of:
|
||||||
|
```yaml
|
||||||
|
something: else
|
||||||
|
---
|
||||||
|
a: simple
|
||||||
|
b: cat
|
||||||
|
```
|
||||||
|
and data3.yaml file of:
|
||||||
|
```yaml
|
||||||
|
b: dog
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq m -x -d1 data1.yaml data3.yaml
|
||||||
|
```
|
||||||
|
will output:
|
||||||
|
```yaml
|
||||||
|
something: else
|
||||||
|
---
|
||||||
|
a: simple
|
||||||
|
b: dog
|
||||||
|
```
|
||||||
|
|
||||||
|
### Multiple Documents - merge into all documents
|
||||||
|
Currently yq only has multi-document support for the _first_ document being merged into. The remaining yaml files will have their first document selected.
|
||||||
|
|
||||||
|
Given a data1.yaml file of:
|
||||||
|
```yaml
|
||||||
|
something: else
|
||||||
|
---
|
||||||
|
a: simple
|
||||||
|
b: cat
|
||||||
|
```
|
||||||
|
and data3.yaml file of:
|
||||||
|
```yaml
|
||||||
|
b: dog
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq m -x -d'*' data1.yaml data3.yaml
|
||||||
|
```
|
||||||
|
will output:
|
||||||
|
```yaml
|
||||||
|
b: dog
|
||||||
|
something: else
|
||||||
|
---
|
||||||
|
a: simple
|
||||||
|
b: dog
|
||||||
|
```
|
||||||
100
mkdocs/read.md
Normal file
100
mkdocs/read.md
Normal file
@@ -0,0 +1,100 @@
|
|||||||
|
```
|
||||||
|
yq r <yaml_file|json_file> <path>
|
||||||
|
```
|
||||||
|
|
||||||
|
{!snippets/works_with_json.md!}
|
||||||
|
|
||||||
|
### Basic
|
||||||
|
Given a sample.yaml file of:
|
||||||
|
```yaml
|
||||||
|
b:
|
||||||
|
c: 2
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq r sample.yaml b.c
|
||||||
|
```
|
||||||
|
will output the value of '2'.
|
||||||
|
|
||||||
|
### From Stdin
|
||||||
|
Given a sample.yaml file of:
|
||||||
|
```bash
|
||||||
|
cat sample.yaml | yq r - b.c
|
||||||
|
```
|
||||||
|
will output the value of '2'.
|
||||||
|
|
||||||
|
### Splat
|
||||||
|
Given a sample.yaml file of:
|
||||||
|
```yaml
|
||||||
|
---
|
||||||
|
bob:
|
||||||
|
item1:
|
||||||
|
cats: bananas
|
||||||
|
item2:
|
||||||
|
cats: apples
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq r sample.yaml bob.*.cats
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
- bananas
|
||||||
|
- apples
|
||||||
|
```
|
||||||
|
|
||||||
|
### Multiple Documents
|
||||||
|
Given a sample.yaml file of:
|
||||||
|
```yaml
|
||||||
|
something: else
|
||||||
|
---
|
||||||
|
b:
|
||||||
|
c: 2
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq r -d1 sample.yaml b.c
|
||||||
|
```
|
||||||
|
will output the value of '2'.
|
||||||
|
|
||||||
|
### Arrays
|
||||||
|
You can give an index to access a specific element:
|
||||||
|
e.g.: given a sample file of
|
||||||
|
```yaml
|
||||||
|
b:
|
||||||
|
e:
|
||||||
|
- name: fred
|
||||||
|
value: 3
|
||||||
|
- name: sam
|
||||||
|
value: 4
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```
|
||||||
|
yq r sample.yaml 'b.e[1].name'
|
||||||
|
```
|
||||||
|
will output 'sam'
|
||||||
|
|
||||||
|
Note that the path is in quotes to avoid the square brackets being interpreted by your shell.
|
||||||
|
|
||||||
|
### Array Splat
|
||||||
|
e.g.: given a sample file of
|
||||||
|
```yaml
|
||||||
|
b:
|
||||||
|
e:
|
||||||
|
- name: fred
|
||||||
|
value: 3
|
||||||
|
- name: sam
|
||||||
|
value: 4
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```
|
||||||
|
yq r sample.yaml 'b.e[*].name'
|
||||||
|
```
|
||||||
|
will output:
|
||||||
|
```
|
||||||
|
- fred
|
||||||
|
- sam
|
||||||
|
```
|
||||||
|
Note that the path is in quotes to avoid the square brackets being interpreted by your shell.
|
||||||
|
|
||||||
|
{!snippets/keys_with_dots.md!}
|
||||||
19
mkdocs/snippets/keys_with_dots.md
Normal file
19
mkdocs/snippets/keys_with_dots.md
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
### Keys with dots
|
||||||
|
When specifying a key that has a dot use key lookup indicator.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
b:
|
||||||
|
foo.bar: 7
|
||||||
|
```
|
||||||
|
|
||||||
|
```bash
|
||||||
|
yaml r sample.yaml 'b[foo.bar]'
|
||||||
|
```
|
||||||
|
|
||||||
|
```bash
|
||||||
|
yaml w sample.yaml 'b[foo.bar]' 9
|
||||||
|
```
|
||||||
|
|
||||||
|
Any valid yaml key can be specified as part of a key lookup.
|
||||||
|
|
||||||
|
Note that the path is in quotes to avoid the square brackets being interpreted by your shell.
|
||||||
1
mkdocs/snippets/works_with_json.md
Normal file
1
mkdocs/snippets/works_with_json.md
Normal file
@@ -0,0 +1 @@
|
|||||||
|
This command can take a json file as input too, and will output yaml unless specified to export as json (-j)
|
||||||
172
mkdocs/write.md
Normal file
172
mkdocs/write.md
Normal file
@@ -0,0 +1,172 @@
|
|||||||
|
```
|
||||||
|
yq w <yaml_file> <path> <new value>
|
||||||
|
```
|
||||||
|
|
||||||
|
### To Stdout
|
||||||
|
Given a sample.yaml file of:
|
||||||
|
```yaml
|
||||||
|
b:
|
||||||
|
c: 2
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq w sample.yaml b.c cat
|
||||||
|
```
|
||||||
|
will output:
|
||||||
|
```yaml
|
||||||
|
b:
|
||||||
|
c: cat
|
||||||
|
```
|
||||||
|
|
||||||
|
### From STDIN
|
||||||
|
```bash
|
||||||
|
cat sample.yaml | yq w - b.c blah
|
||||||
|
```
|
||||||
|
|
||||||
|
### Adding new fields
|
||||||
|
Any missing fields in the path will be created on the fly.
|
||||||
|
|
||||||
|
Given a sample.yaml file of:
|
||||||
|
```yaml
|
||||||
|
b:
|
||||||
|
c: 2
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq w sample.yaml b.d[0] "new thing"
|
||||||
|
```
|
||||||
|
will output:
|
||||||
|
```yaml
|
||||||
|
b:
|
||||||
|
c: cat
|
||||||
|
d:
|
||||||
|
- new thing
|
||||||
|
```
|
||||||
|
|
||||||
|
### Appending value to an array field
|
||||||
|
Given a sample.yaml file of:
|
||||||
|
```yaml
|
||||||
|
b:
|
||||||
|
c: 2
|
||||||
|
d:
|
||||||
|
- new thing
|
||||||
|
- foo thing
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq w sample.yaml "b.d[+]" "bar thing"
|
||||||
|
```
|
||||||
|
will output:
|
||||||
|
```yaml
|
||||||
|
b:
|
||||||
|
c: cat
|
||||||
|
d:
|
||||||
|
- new thing
|
||||||
|
- foo thing
|
||||||
|
- bar thing
|
||||||
|
```
|
||||||
|
|
||||||
|
Note that the path is in quotes to avoid the square brackets being interpreted by your shell.
|
||||||
|
|
||||||
|
### Multiple Documents - update a single document
|
||||||
|
Given a sample.yaml file of:
|
||||||
|
```yaml
|
||||||
|
something: else
|
||||||
|
---
|
||||||
|
b:
|
||||||
|
c: 2
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq w -d1 sample.yaml b.c 5
|
||||||
|
```
|
||||||
|
will output:
|
||||||
|
```yaml
|
||||||
|
something: else
|
||||||
|
---
|
||||||
|
b:
|
||||||
|
c: 5
|
||||||
|
```
|
||||||
|
|
||||||
|
### Multiple Documents - update all documents
|
||||||
|
Given a sample.yaml file of:
|
||||||
|
```yaml
|
||||||
|
something: else
|
||||||
|
---
|
||||||
|
b:
|
||||||
|
c: 2
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq w -d'*' sample.yaml b.c 5
|
||||||
|
```
|
||||||
|
will output:
|
||||||
|
```yaml
|
||||||
|
something: else
|
||||||
|
b:
|
||||||
|
c: 5
|
||||||
|
---
|
||||||
|
b:
|
||||||
|
c: 5
|
||||||
|
```
|
||||||
|
|
||||||
|
Note that '*' is in quotes to avoid being interpreted by your shell.
|
||||||
|
|
||||||
|
### Updating files in-place
|
||||||
|
Given a sample.yaml file of:
|
||||||
|
```yaml
|
||||||
|
b:
|
||||||
|
c: 2
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq w -i sample.yaml b.c cat
|
||||||
|
```
|
||||||
|
will update the sample.yaml file so that the value of 'c' is cat.
|
||||||
|
|
||||||
|
|
||||||
|
### Updating multiple values with a script
|
||||||
|
Given a sample.yaml file of:
|
||||||
|
```yaml
|
||||||
|
b:
|
||||||
|
c: 2
|
||||||
|
e:
|
||||||
|
- name: Billy Bob
|
||||||
|
```
|
||||||
|
and a script update_instructions.yaml of:
|
||||||
|
```yaml
|
||||||
|
b.c: 3
|
||||||
|
b.e[0].name: Howdy Partner
|
||||||
|
```
|
||||||
|
then
|
||||||
|
|
||||||
|
```bash
|
||||||
|
yq w -s update_instructions.yaml sample.yaml
|
||||||
|
```
|
||||||
|
will output:
|
||||||
|
```yaml
|
||||||
|
b:
|
||||||
|
c: 3
|
||||||
|
e:
|
||||||
|
- name: Howdy Partner
|
||||||
|
```
|
||||||
|
|
||||||
|
And, of course, you can pipe the instructions in using '-':
|
||||||
|
```bash
|
||||||
|
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:
|
||||||
|
|
||||||
|
```
|
||||||
|
yq w -- my.path -3
|
||||||
|
```
|
||||||
|
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
my:
|
||||||
|
path: -3
|
||||||
|
```
|
||||||
|
|
||||||
|
{!snippets/keys_with_dots.md!}
|
||||||
@@ -16,13 +16,13 @@ func nextYamlPath(path string) (pathElement string, remaining string) {
|
|||||||
switch path[0] {
|
switch path[0] {
|
||||||
case '[':
|
case '[':
|
||||||
// e.g [0].blah.cat -> we need to return "0" and "blah.cat"
|
// e.g [0].blah.cat -> we need to return "0" and "blah.cat"
|
||||||
return search(path[1:len(path)], []uint8{']'}, true)
|
return search(path[1:], []uint8{']'}, true)
|
||||||
case '"':
|
case '"':
|
||||||
// e.g "a.b".blah.cat -> we need to return "a.b" and "blah.cat"
|
// e.g "a.b".blah.cat -> we need to return "a.b" and "blah.cat"
|
||||||
return search(path[1:len(path)], []uint8{'"'}, true)
|
return search(path[1:], []uint8{'"'}, true)
|
||||||
default:
|
default:
|
||||||
// e.g "a.blah.cat" -> return "a" and "blah.cat"
|
// e.g "a.blah.cat" -> return "a" and "blah.cat"
|
||||||
return search(path[0:len(path)], []uint8{'.', '['}, false)
|
return search(path[0:], []uint8{'.', '['}, false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -39,7 +39,7 @@ func search(path string, matchingChars []uint8, skipNext bool) (pathElement stri
|
|||||||
if remainingStart > len(path) {
|
if remainingStart > len(path) {
|
||||||
remainingStart = len(path)
|
remainingStart = len(path)
|
||||||
}
|
}
|
||||||
return path[0:i], path[remainingStart:len(path)]
|
return path[0:i], path[remainingStart:]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return path, ""
|
return path, ""
|
||||||
|
|||||||
@@ -10,11 +10,12 @@ var parsePathsTests = []struct {
|
|||||||
}{
|
}{
|
||||||
{"a.b", []string{"a", "b"}},
|
{"a.b", []string{"a", "b"}},
|
||||||
{"a.b[0]", []string{"a", "b", "0"}},
|
{"a.b[0]", []string{"a", "b", "0"}},
|
||||||
|
{"a.b.d[+]", []string{"a", "b", "d", "+"}},
|
||||||
}
|
}
|
||||||
|
|
||||||
func testParsePath(t *testing.T) {
|
func TestParsePath(t *testing.T) {
|
||||||
for _, tt := range parsePathsTests {
|
for _, tt := range parsePathsTests {
|
||||||
assertResultWithContext(t, tt.expectedPaths, parsePath(tt.path), tt)
|
assertResultComplex(t, tt.expectedPaths, parsePath(tt.path))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,17 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
gofmt -w .
|
|
||||||
golint
|
|
||||||
go test
|
|
||||||
|
|
||||||
# acceptance test
|
|
||||||
go build
|
|
||||||
X=$(./yaml r sample.yaml b.c)
|
|
||||||
|
|
||||||
if [ $X != 2 ]
|
|
||||||
then
|
|
||||||
echo "Failed acceptance test: expected 2 but was $X"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
go install
|
|
||||||
37
release_instructions.txt
Normal file
37
release_instructions.txt
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
- increment version in version.go
|
||||||
|
- increment version in snapcraft.yaml
|
||||||
|
- tag git with same version number, be sure to start with 'v' for gopkg.in
|
||||||
|
- make sure local build passes
|
||||||
|
- push tag to git
|
||||||
|
- make local xcompile (builds binaries for all platforms)
|
||||||
|
|
||||||
|
- git release
|
||||||
|
./scripts/publish.sh
|
||||||
|
|
||||||
|
- snapcraft
|
||||||
|
- will auto create a candidate, test it works then promote
|
||||||
|
- see https://build.snapcraft.io/user/mikefarah/yq
|
||||||
|
|
||||||
|
sudo snap remove yq
|
||||||
|
sudo snap install --edge yq
|
||||||
|
|
||||||
|
then on the mac snapcraft release yq <snap_build_number> stable
|
||||||
|
|
||||||
|
|
||||||
|
- brew
|
||||||
|
- create pull request pointing to latest git release
|
||||||
|
|
||||||
|
- docker
|
||||||
|
- build and push latest and new version tag
|
||||||
|
|
||||||
|
- debian package
|
||||||
|
- execute
|
||||||
|
```dch -i```
|
||||||
|
- fill debian/changelog with changes from last version
|
||||||
|
- build the package sources
|
||||||
|
```debuild -i -I -S -sa```
|
||||||
|
(signing with gpg key is required in order to put it to ppa)
|
||||||
|
- put to PPA
|
||||||
|
```dput ppa:<REPOSITORY> ../yq_<VERSION>_source.changes```
|
||||||
|
(current distro repository is ppa:rmescandon/yq. In case that a new version
|
||||||
|
is released, please contact rmescandon@gmail.com to bump debian package)
|
||||||
12
scripts/acceptance.sh
Executable file
12
scripts/acceptance.sh
Executable file
@@ -0,0 +1,12 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# acceptance test
|
||||||
|
X=$(./yq w ./examples/sample.yaml b.c 3 | ./yq r - b.c)
|
||||||
|
|
||||||
|
if [[ $X != 3 ]]; then
|
||||||
|
echo "Failed acceptance test: expected 2 but was $X"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "acceptance tests passed"
|
||||||
26
scripts/check.sh
Executable file
26
scripts/check.sh
Executable file
@@ -0,0 +1,26 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -o errexit
|
||||||
|
set -o pipefail
|
||||||
|
|
||||||
|
gometalinter \
|
||||||
|
--skip=examples \
|
||||||
|
--tests \
|
||||||
|
--vendor \
|
||||||
|
--disable=aligncheck \
|
||||||
|
--disable=gotype \
|
||||||
|
--disable=goconst \
|
||||||
|
--cyclo-over=20 \
|
||||||
|
--deadline=300s \
|
||||||
|
./...
|
||||||
|
|
||||||
|
gometalinter \
|
||||||
|
--skip=examples \
|
||||||
|
--tests \
|
||||||
|
--vendor \
|
||||||
|
--disable=aligncheck \
|
||||||
|
--disable=gotype \
|
||||||
|
--disable=goconst \
|
||||||
|
--disable=gocyclo \
|
||||||
|
--deadline=300s \
|
||||||
|
./...
|
||||||
6
scripts/coverage.sh
Executable file
6
scripts/coverage.sh
Executable file
@@ -0,0 +1,6 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
go test -coverprofile=coverage.out
|
||||||
|
go tool cover -html=coverage.out -o cover/coverage.html
|
||||||
10
scripts/devtools.sh
Executable file
10
scripts/devtools.sh
Executable file
@@ -0,0 +1,10 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
go get -u github.com/alecthomas/gometalinter
|
||||||
|
go get -u golang.org/x/tools/cmd/goimports
|
||||||
|
go get -u github.com/mitchellh/gox
|
||||||
|
go get -u github.com/kardianos/govendor
|
||||||
|
go get -u github.com/aktau/github-release
|
||||||
|
|
||||||
|
# install all the linters
|
||||||
|
gometalinter --install --update
|
||||||
6
scripts/doctools.sh
Normal file
6
scripts/doctools.sh
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
#!/bin.bash
|
||||||
|
|
||||||
|
brew install mkdocs libyaml
|
||||||
|
pip3 install markdown-include
|
||||||
|
pip3 install mkdocs-material
|
||||||
|
|
||||||
3
scripts/format.sh
Executable file
3
scripts/format.sh
Executable file
@@ -0,0 +1,3 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
find . \( -path ./vendor \) -prune -o -name "*.go" -exec goimports -w {} \;
|
||||||
33
scripts/publish.sh
Executable file
33
scripts/publish.sh
Executable file
@@ -0,0 +1,33 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -ex
|
||||||
|
GITHUB_TOKEN="${GITHUB_TOKEN:?missing required input \'GITHUB_TOKEN\'}"
|
||||||
|
|
||||||
|
CURRENT="$(git describe --tags --abbrev=0)"
|
||||||
|
PREVIOUS="$(git describe --tags --abbrev=0 --always "${CURRENT}"^)"
|
||||||
|
OWNER="mikefarah"
|
||||||
|
REPO="yq"
|
||||||
|
|
||||||
|
release() {
|
||||||
|
github-release release \
|
||||||
|
--user "$OWNER" \
|
||||||
|
--repo "$REPO" \
|
||||||
|
--tag "$CURRENT"
|
||||||
|
}
|
||||||
|
|
||||||
|
upload() {
|
||||||
|
while IFS= read -r -d $'\0'; do
|
||||||
|
file=$REPLY
|
||||||
|
BINARY=$(basename "${file}")
|
||||||
|
echo "--> ${BINARY}"
|
||||||
|
github-release upload \
|
||||||
|
--replace \
|
||||||
|
--user "$OWNER" \
|
||||||
|
--repo "$REPO" \
|
||||||
|
--tag "$CURRENT" \
|
||||||
|
--name "${BINARY}" \
|
||||||
|
--file "$file"
|
||||||
|
done < <(find ./build -mindepth 1 -maxdepth 1 -print0)
|
||||||
|
}
|
||||||
|
|
||||||
|
release
|
||||||
|
upload
|
||||||
92
scripts/setup.sh
Executable file
92
scripts/setup.sh
Executable file
@@ -0,0 +1,92 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -eu
|
||||||
|
|
||||||
|
find_mgr() {
|
||||||
|
if hash minishift 2>/dev/null; then
|
||||||
|
echo "minishift"
|
||||||
|
else
|
||||||
|
if hash docker-machine 2>/dev/null; then
|
||||||
|
echo "docker-machine"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
get_vm_name() {
|
||||||
|
case "$1" in
|
||||||
|
minishift)
|
||||||
|
echo "minishift"
|
||||||
|
;;
|
||||||
|
docker-machine)
|
||||||
|
echo "${DOCKER_MACHINE_NAME}"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
is_vm_running() {
|
||||||
|
local vm=$1
|
||||||
|
declare -a running=($(VBoxManage list runningvms | awk '{ print $1 }'))
|
||||||
|
local result='false'
|
||||||
|
|
||||||
|
for rvm in "${running[@]}"; do
|
||||||
|
if [[ "${rvm}" == *"${vm}"* ]]; then
|
||||||
|
result='true'
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
echo "$result"
|
||||||
|
}
|
||||||
|
|
||||||
|
if hash cygpath 2>/dev/null; then
|
||||||
|
PROJECT_DIR=$(cygpath -w -a "$(pwd)")
|
||||||
|
else
|
||||||
|
PROJECT_DIR=$(pwd)
|
||||||
|
fi
|
||||||
|
|
||||||
|
VM_MGR=$(find_mgr)
|
||||||
|
if [[ -z $VM_MGR ]]; then
|
||||||
|
echo "ERROR: No VM Manager found; expected one of ['minishift', 'docker-machine']"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
VM_NAME=$(get_vm_name "$VM_MGR")
|
||||||
|
if [[ -z $VM_NAME ]]; then
|
||||||
|
echo "ERROR: No VM found; try running 'eval $(docker-machine env)'"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! hash VBoxManage 2>/dev/null; then
|
||||||
|
echo "VirtualBox executable 'VBoxManage' not found in path"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
avail=$(is_vm_running "$VM_NAME")
|
||||||
|
if [[ "$avail" == *"true"* ]]; then
|
||||||
|
res=$(VBoxManage sharedfolder add "${VM_NAME}" --name "${PROJECT}" --hostpath "${PROJECT_DIR}" --transient 2>&1)
|
||||||
|
if [[ -z $res || $res == *"already exists"* ]]; then
|
||||||
|
# no need to show that it already exists
|
||||||
|
:
|
||||||
|
else
|
||||||
|
echo "$res"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "VM: [${VM_NAME}] -- Added Sharedfolder [${PROJECT}] @Path [${PROJECT_DIR}]"
|
||||||
|
else
|
||||||
|
echo "$VM_NAME is not currently running; please start your VM and try again."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
SSH_CMD="sudo mkdir -p /${PROJECT} ; sudo mount -t vboxsf ${PROJECT} /${PROJECT}"
|
||||||
|
case "${VM_MGR}" in
|
||||||
|
minishift)
|
||||||
|
minishift ssh "${SSH_CMD}"
|
||||||
|
echo "VM: [${VM_NAME}] -- Mounted Sharedfolder [${PROJECT}] @VM Path [/${PROJECT}]"
|
||||||
|
;;
|
||||||
|
docker-machine)
|
||||||
|
docker-machine ssh "${VM_NAME}" "${SSH_CMD}"
|
||||||
|
echo "VM: [${VM_NAME}] -- Mounted Sharedfolder [${PROJECT}] @VM Path [/${PROJECT}]"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
;;
|
||||||
|
esac
|
||||||
3
scripts/test.sh
Executable file
3
scripts/test.sh
Executable file
@@ -0,0 +1,3 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
go test -v $(go list ./... | grep -v -E 'vendor|examples')
|
||||||
@@ -3,5 +3,5 @@
|
|||||||
# This assumes that gonative and gox is installed as per the 'one time setup' instructions
|
# This assumes that gonative and gox is installed as per the 'one time setup' instructions
|
||||||
# at https://github.com/inconshreveable/gonative
|
# at https://github.com/inconshreveable/gonative
|
||||||
|
|
||||||
gox -output="build/{{.Dir}}_{{.OS}}_{{.Arch}}"
|
gox -ldflags "${LDFLAGS}" -output="build/{{.Dir}}_{{.OS}}_{{.Arch}}"
|
||||||
|
|
||||||
22
snap/snapcraft.yaml
Normal file
22
snap/snapcraft.yaml
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
name: yq
|
||||||
|
version: 2.0.0
|
||||||
|
summary: A lightweight and portable command-line YAML processor
|
||||||
|
description: |
|
||||||
|
The aim of the project is to be the jq or sed of yaml files.
|
||||||
|
|
||||||
|
grade: stable # devel|stable. must be 'stable' to release into candidate/stable channels
|
||||||
|
confinement: strict
|
||||||
|
|
||||||
|
apps:
|
||||||
|
yq:
|
||||||
|
command: yq
|
||||||
|
plugs: [home]
|
||||||
|
|
||||||
|
parts:
|
||||||
|
yq:
|
||||||
|
plugin: go
|
||||||
|
source: .
|
||||||
|
go-importpath: github.com/mikefarah/yq
|
||||||
|
after: [go]
|
||||||
|
go:
|
||||||
|
source-tag: go1.9.4
|
||||||
82
utils_test.go
Normal file
82
utils_test.go
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
|
"os"
|
||||||
|
"reflect"
|
||||||
|
"strings"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
yaml "gopkg.in/mikefarah/yaml.v2"
|
||||||
|
"gopkg.in/spf13/cobra.v0"
|
||||||
|
)
|
||||||
|
|
||||||
|
type resulter struct {
|
||||||
|
Error error
|
||||||
|
Output string
|
||||||
|
Command *cobra.Command
|
||||||
|
}
|
||||||
|
|
||||||
|
func runCmd(c *cobra.Command, input string) resulter {
|
||||||
|
buf := new(bytes.Buffer)
|
||||||
|
c.SetOutput(buf)
|
||||||
|
c.SetArgs(strings.Split(input, " "))
|
||||||
|
|
||||||
|
err := c.Execute()
|
||||||
|
output := buf.String()
|
||||||
|
|
||||||
|
return resulter{err, output, c}
|
||||||
|
}
|
||||||
|
|
||||||
|
func parseData(rawData string) yaml.MapSlice {
|
||||||
|
var parsedData yaml.MapSlice
|
||||||
|
err := yaml.Unmarshal([]byte(rawData), &parsedData)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Printf("Error parsing yaml: %v\n", err)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
return parsedData
|
||||||
|
}
|
||||||
|
|
||||||
|
func assertResult(t *testing.T, expectedValue interface{}, actualValue interface{}) {
|
||||||
|
t.Helper()
|
||||||
|
if expectedValue != actualValue {
|
||||||
|
t.Error("Expected <", expectedValue, "> but got <", actualValue, ">", fmt.Sprintf("%T", actualValue))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func assertResultComplex(t *testing.T, expectedValue interface{}, actualValue interface{}) {
|
||||||
|
t.Helper()
|
||||||
|
if !reflect.DeepEqual(expectedValue, actualValue) {
|
||||||
|
t.Error("Expected <", expectedValue, "> but got <", actualValue, ">", fmt.Sprintf("%T", actualValue))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func assertResultWithContext(t *testing.T, expectedValue interface{}, actualValue interface{}, context interface{}) {
|
||||||
|
t.Helper()
|
||||||
|
if expectedValue != actualValue {
|
||||||
|
t.Error(context)
|
||||||
|
t.Error(": expected <", expectedValue, "> but got <", actualValue, ">")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func writeTempYamlFile(content string) string {
|
||||||
|
tmpfile, _ := ioutil.TempFile("", "testyaml")
|
||||||
|
defer func() {
|
||||||
|
_ = tmpfile.Close()
|
||||||
|
}()
|
||||||
|
|
||||||
|
_, _ = tmpfile.Write([]byte(content))
|
||||||
|
return tmpfile.Name()
|
||||||
|
}
|
||||||
|
|
||||||
|
func readTempYamlFile(name string) string {
|
||||||
|
content, _ := ioutil.ReadFile(name)
|
||||||
|
return string(content)
|
||||||
|
}
|
||||||
|
|
||||||
|
func removeTempYamlFile(name string) {
|
||||||
|
_ = os.Remove(name)
|
||||||
|
}
|
||||||
49
vendor/vendor.json
vendored
Normal file
49
vendor/vendor.json
vendored
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
{
|
||||||
|
"comment": "",
|
||||||
|
"ignore": "test",
|
||||||
|
"package": [
|
||||||
|
{
|
||||||
|
"checksumSHA1": "40vJyUB4ezQSn/NSadsKEOrudMc=",
|
||||||
|
"path": "github.com/inconshreveable/mousetrap",
|
||||||
|
"revision": "76626ae9c91c4f2a10f34cad8ce83ea42c93bb75",
|
||||||
|
"revisionTime": "2014-10-17T20:07:13Z"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"checksumSHA1": "ljd3FhYRJ91cLZz3wsH9BQQ2JbA=",
|
||||||
|
"path": "github.com/pkg/errors",
|
||||||
|
"revision": "816c9085562cd7ee03e7f8188a1cfd942858cded",
|
||||||
|
"revisionTime": "2018-03-11T21:45:15Z"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"checksumSHA1": "OJI0OgC5V8gZtfS1e0CDYMhkDNc=",
|
||||||
|
"path": "github.com/spf13/pflag",
|
||||||
|
"revision": "3ebe029320b2676d667ae88da602a5f854788a8a",
|
||||||
|
"revisionTime": "2018-06-01T13:25:42Z"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"checksumSHA1": "RwlkCZz8VFXAE4aHQQOSC0hLu5k=",
|
||||||
|
"path": "gopkg.in/imdario/mergo.v0",
|
||||||
|
"revision": "9316a62528ac99aaecb4e47eadd6dc8aa6533d58",
|
||||||
|
"revisionTime": "2018-06-08T14:01:56Z"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"checksumSHA1": "7wtGubs4v7+RZovtlmyT9KwA/gE=",
|
||||||
|
"path": "gopkg.in/mikefarah/yaml.v2",
|
||||||
|
"revision": "e175af14aaa1d0eff2ee04b691e4a4827a111416",
|
||||||
|
"revisionTime": "2018-06-13T04:05:11Z"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"checksumSHA1": "rL5r44ASTGubGW88gqQwlvVQshw=",
|
||||||
|
"path": "gopkg.in/op/go-logging.v1",
|
||||||
|
"revision": "b2cb9fa56473e98db8caba80237377e83fe44db5",
|
||||||
|
"revisionTime": "2016-02-11T21:21:56Z"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"checksumSHA1": "xsZjAbfLrXcMtY6fyQ8QC6EvJD0=",
|
||||||
|
"path": "gopkg.in/spf13/cobra.v0",
|
||||||
|
"revision": "ef82de70bb3f60c65fb8eebacbb2d122ef517385",
|
||||||
|
"revisionTime": "2018-04-27T13:45:50Z"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"rootPath": "github.com/mikefarah/yq"
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user