mirror of
https://github.com/taigrr/yq
synced 2025-01-18 04:53:17 -08:00
Compare commits
24 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
54c73eb34f | ||
|
|
3b03a0852a | ||
|
|
a00e6c5316 | ||
|
|
9d1a5b17b8 | ||
|
|
c5f80a105d | ||
|
|
c17f8df8f8 | ||
|
|
66c8390d54 | ||
|
|
dda9b1f087 | ||
|
|
683de28c64 | ||
|
|
51fa1a87b7 | ||
|
|
b9ac6a3d9d | ||
|
|
499974c27e | ||
|
|
72bd88cfa5 | ||
|
|
6980be3800 | ||
|
|
2933ea1684 | ||
|
|
cf2f23d747 | ||
|
|
45e9ad870f | ||
|
|
53b2c64747 | ||
|
|
359ca5a117 | ||
|
|
79baa49eaa | ||
|
|
2cda78ce0b | ||
|
|
6d1e61c410 | ||
|
|
86639acf70 | ||
|
|
3beee3f804 |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -6,6 +6,7 @@
|
|||||||
# Folders
|
# Folders
|
||||||
_obj
|
_obj
|
||||||
_test
|
_test
|
||||||
|
bin
|
||||||
build
|
build
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
|
||||||
@@ -26,3 +27,5 @@ coverage.out
|
|||||||
*.prof
|
*.prof
|
||||||
yaml
|
yaml
|
||||||
vendor/*/
|
vendor/*/
|
||||||
|
tmp/
|
||||||
|
cover/
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
language: go
|
language: go
|
||||||
go:
|
go:
|
||||||
- 1.7.x
|
- 1.7.x
|
||||||
script: ./ci.sh
|
script:
|
||||||
|
- scripts/devtools.sh
|
||||||
|
- make local build
|
||||||
|
|||||||
28
Dockerfile.dev
Normal file
28
Dockerfile.dev
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
FROM golang:1.7
|
||||||
|
|
||||||
|
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-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:/yaml
|
||||||
119
Makefile
Normal file
119
Makefile
Normal file
@@ -0,0 +1,119 @@
|
|||||||
|
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 yaml binary.'
|
||||||
|
@echo ' make install Install yaml.'
|
||||||
|
@echo ' make xcompile Build cross-compiled binaries of yaml.'
|
||||||
|
@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
|
||||||
|
|
||||||
|
veryclean: clean
|
||||||
|
rm -rf tmp
|
||||||
|
find vendor/* -maxdepth 0 -ignore_readdir_race -type d -exec rm -rf {} \;
|
||||||
|
|
||||||
|
## 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 -o bin/yaml --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: 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} bash ./scripts/vendor.sh
|
||||||
|
@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 = yaml
|
||||||
|
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}
|
||||||
22
README.md
22
README.md
@@ -20,6 +20,8 @@ go get github.com/mikefarah/yaml
|
|||||||
- Convert from json to yaml
|
- Convert from json to yaml
|
||||||
- Convert from yaml to json
|
- Convert from yaml to json
|
||||||
- Pipe data in by using '-'
|
- 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.
|
||||||
|
|
||||||
## [Usage](http://mikefarah.github.io/yaml/)
|
## [Usage](http://mikefarah.github.io/yaml/)
|
||||||
|
|
||||||
@@ -27,25 +29,29 @@ Check out the [documentation](http://mikefarah.github.io/yaml/) for more detaile
|
|||||||
|
|
||||||
```
|
```
|
||||||
Usage:
|
Usage:
|
||||||
|
yaml [flags]
|
||||||
yaml [command]
|
yaml [command]
|
||||||
|
|
||||||
Available Commands:
|
Available Commands:
|
||||||
|
help Help about any command
|
||||||
|
merge yaml m [--inplace/-i] [--overwrite/-x] sample.yaml sample2.yaml
|
||||||
|
new yaml n [--script/-s script_file] a.b.c newValueForC
|
||||||
read yaml r sample.yaml a.b.c
|
read yaml r sample.yaml a.b.c
|
||||||
write yaml w [--inplace/-i] [--script/-s script_file] sample.yaml a.b.c newValueForC
|
write yaml w [--inplace/-i] [--script/-s script_file] sample.yaml a.b.c newValueForC
|
||||||
new yaml n [--script/-s script_file] a.b.c newValueForC
|
|
||||||
|
|
||||||
Flags:
|
Flags:
|
||||||
-h, --help[=false]: help for yaml
|
-h, --help help for yaml
|
||||||
-j, --tojson[=false]: output as json
|
-j, --tojson output as json
|
||||||
-t, --trim[=true]: trim yaml output
|
-t, --trim trim yaml output (default true)
|
||||||
-v, --verbose[=false]: verbose mode
|
-v, --verbose verbose mode
|
||||||
|
-V, --version Print version information and quit
|
||||||
|
|
||||||
Use "yaml [command] --help" for more information about a command.
|
Use "yaml [command] --help" for more information about a command.
|
||||||
```
|
```
|
||||||
|
|
||||||
## Contribute
|
## Contribute
|
||||||
1. run `govendor sync` [link](https://github.com/kardianos/govendor)
|
1. `make vendor` OR run `govendor sync` [link](https://github.com/kardianos/govendor)
|
||||||
2. add unit tests
|
2. add unit tests
|
||||||
3. make changes
|
3. apply changes
|
||||||
4. run ./precheckin.sh
|
4. `make`
|
||||||
5. profit
|
5. profit
|
||||||
|
|||||||
526
commands_test.go
Normal file
526
commands_test.go
Normal file
@@ -0,0 +1,526 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
)
|
||||||
|
|
||||||
|
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_ToJsonLong(t *testing.T) {
|
||||||
|
cmd := getRootCommand()
|
||||||
|
result := runCmd(cmd, "--tojson")
|
||||||
|
if result.Error != nil {
|
||||||
|
t.Error(result.Error)
|
||||||
|
}
|
||||||
|
|
||||||
|
if !outputToJSON {
|
||||||
|
t.Error("Expected outputToJSON to be true")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestRootCmd_ToJsonShort(t *testing.T) {
|
||||||
|
cmd := getRootCommand()
|
||||||
|
result := runCmd(cmd, "-j")
|
||||||
|
if result.Error != nil {
|
||||||
|
t.Error(result.Error)
|
||||||
|
}
|
||||||
|
|
||||||
|
if !outputToJSON {
|
||||||
|
t.Error("Expected outputToJSON 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, "yaml 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, "yaml 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 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 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 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 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, "-j read 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 TestNewCmd_ToJson(t *testing.T) {
|
||||||
|
cmd := getRootCommand()
|
||||||
|
result := runCmd(cmd, "-j 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 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, gotOutput)
|
||||||
|
}
|
||||||
|
|
||||||
|
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 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 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 := `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, gotOutput)
|
||||||
|
}
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
go test -coverprofile=coverage.out && go tool cover -html=coverage.out
|
|
||||||
@@ -1,8 +1,11 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"gopkg.in/yaml.v2"
|
"fmt"
|
||||||
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
|
"gopkg.in/yaml.v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
func entryInSlice(context yaml.MapSlice, key interface{}) *yaml.MapItem {
|
func entryInSlice(context yaml.MapSlice, key interface{}) *yaml.MapItem {
|
||||||
@@ -40,7 +43,7 @@ func writeMap(context interface{}, paths []string, value interface{}) yaml.MapSl
|
|||||||
|
|
||||||
log.Debugf("\tchild.Value %v\n", child.Value)
|
log.Debugf("\tchild.Value %v\n", child.Value)
|
||||||
|
|
||||||
remainingPaths := paths[1:len(paths)]
|
remainingPaths := paths[1:]
|
||||||
child.Value = updatedChildValue(child.Value, remainingPaths, value)
|
child.Value = updatedChildValue(child.Value, remainingPaths, value)
|
||||||
log.Debugf("\tReturning mapSlice %v\n", mapSlice)
|
log.Debugf("\tReturning mapSlice %v\n", mapSlice)
|
||||||
return mapSlice
|
return mapSlice
|
||||||
@@ -52,7 +55,7 @@ func updatedChildValue(child interface{}, remainingPaths []string, value interfa
|
|||||||
}
|
}
|
||||||
|
|
||||||
_, nextIndexErr := strconv.ParseInt(remainingPaths[0], 10, 64)
|
_, nextIndexErr := strconv.ParseInt(remainingPaths[0], 10, 64)
|
||||||
if nextIndexErr != nil {
|
if nextIndexErr != nil && remainingPaths[0] != "+" {
|
||||||
// must be a map
|
// must be a map
|
||||||
return writeMap(child, remainingPaths, value)
|
return writeMap(child, remainingPaths, value)
|
||||||
}
|
}
|
||||||
@@ -78,10 +81,18 @@ func writeArray(context interface{}, paths []string, value interface{}) []interf
|
|||||||
log.Debugf("\tarray %v\n", array)
|
log.Debugf("\tarray %v\n", array)
|
||||||
|
|
||||||
rawIndex := paths[0]
|
rawIndex := paths[0]
|
||||||
index, err := strconv.ParseInt(rawIndex, 10, 64)
|
var index int64
|
||||||
if err != nil {
|
// the append array indicator
|
||||||
die("Error accessing array: %v", err)
|
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)) {
|
for index >= int64(len(array)) {
|
||||||
array = append(array, nil)
|
array = append(array, nil)
|
||||||
}
|
}
|
||||||
@@ -89,13 +100,13 @@ func writeArray(context interface{}, paths []string, value interface{}) []interf
|
|||||||
|
|
||||||
log.Debugf("\tcurrentChild %v\n", currentChild)
|
log.Debugf("\tcurrentChild %v\n", currentChild)
|
||||||
|
|
||||||
remainingPaths := paths[1:len(paths)]
|
remainingPaths := paths[1:]
|
||||||
array[index] = updatedChildValue(currentChild, remainingPaths, value)
|
array[index] = updatedChildValue(currentChild, remainingPaths, value)
|
||||||
log.Debugf("\tReturning array %v\n", array)
|
log.Debugf("\tReturning array %v\n", array)
|
||||||
return array
|
return array
|
||||||
}
|
}
|
||||||
|
|
||||||
func readMap(context yaml.MapSlice, head string, tail []string) interface{} {
|
func readMap(context yaml.MapSlice, head string, tail []string) (interface{}, error) {
|
||||||
if head == "*" {
|
if head == "*" {
|
||||||
return readMapSplat(context, tail)
|
return readMapSplat(context, tail)
|
||||||
}
|
}
|
||||||
@@ -108,21 +119,25 @@ func readMap(context yaml.MapSlice, head string, tail []string) interface{} {
|
|||||||
return calculateValue(value, tail)
|
return calculateValue(value, tail)
|
||||||
}
|
}
|
||||||
|
|
||||||
func readMapSplat(context yaml.MapSlice, 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 _, entry := range context {
|
for _, entry := range context {
|
||||||
if len(tail) > 0 {
|
if len(tail) > 0 {
|
||||||
newArray[i] = recurse(entry.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] = entry.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 == "*" {
|
||||||
@@ -130,37 +145,75 @@ 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 yaml.MapSlice:
|
case yaml.MapSlice:
|
||||||
return readMap(value.(yaml.MapSlice), 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 mapToMapSlice(data map[interface{}]interface{}) yaml.MapSlice {
|
||||||
|
var mapSlice yaml.MapSlice
|
||||||
|
|
||||||
|
for k, v := range data {
|
||||||
|
if mv, ok := v.(map[interface{}]interface{}); ok {
|
||||||
|
v = mapToMapSlice(mv)
|
||||||
|
}
|
||||||
|
item := yaml.MapItem{Key: k, Value: v}
|
||||||
|
mapSlice = append(mapSlice, item)
|
||||||
|
}
|
||||||
|
|
||||||
|
// because the parsing of the yaml was done via a map the order will be inconsistent
|
||||||
|
// apply order to allow a consistent output
|
||||||
|
// Only available in Go 1.8+
|
||||||
|
// sort.SliceStable(mapSlice, func(i, j int) bool { return mapSlice[i].Key < mapSlice[j].Key })
|
||||||
|
sort.Sort(sortMap{mapSlice})
|
||||||
|
return mapSlice
|
||||||
|
}
|
||||||
|
|
||||||
|
type sortMap struct {
|
||||||
|
ms yaml.MapSlice
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m sortMap) Len() int {
|
||||||
|
return len(m.ms)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m sortMap) Less(i, j int) bool {
|
||||||
|
return m.ms[i].Key.(string) < m.ms[j].Key.(string)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m sortMap) Swap(i, j int) {
|
||||||
|
m.ms[i], m.ms[j] = m.ms[j], m.ms[i]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,18 +2,11 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/op/go-logging"
|
|
||||||
"gopkg.in/yaml.v2"
|
|
||||||
"os"
|
|
||||||
"sort"
|
"sort"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
|
||||||
|
|
||||||
func TestMain(m *testing.M) {
|
yaml "gopkg.in/yaml.v2"
|
||||||
backend.SetLevel(logging.ERROR, "")
|
)
|
||||||
logging.SetBackend(backend)
|
|
||||||
os.Exit(m.Run())
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestReadMap_simple(t *testing.T) {
|
func TestReadMap_simple(t *testing.T) {
|
||||||
var data = parseData(`
|
var data = parseData(`
|
||||||
@@ -21,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) {
|
||||||
@@ -31,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))
|
||||||
@@ -47,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))
|
||||||
@@ -59,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) {
|
||||||
@@ -67,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) {
|
||||||
@@ -78,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) {
|
||||||
@@ -89,7 +144,8 @@ 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) {
|
func TestReadMap_with_array_out_of_bounds_by_1(t *testing.T) {
|
||||||
@@ -100,7 +156,8 @@ b:
|
|||||||
- 3
|
- 3
|
||||||
- 4
|
- 4
|
||||||
`)
|
`)
|
||||||
assertResult(t, nil, readMap(data, "b", []string{"d", "2"}))
|
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) {
|
||||||
@@ -113,7 +170,8 @@ 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) {
|
func TestWrite_really_simple(t *testing.T) {
|
||||||
@@ -157,7 +215,8 @@ b:
|
|||||||
`)
|
`)
|
||||||
|
|
||||||
updated := writeMap(data, []string{"b", "d", "f"}, "4")
|
updated := writeMap(data, []string{"b", "d", "f"}, "4")
|
||||||
assertResult(t, "4", readMap(updated, "b", []string{"d", "f"}))
|
got, _ := readMap(updated, "b", []string{"d", "f"})
|
||||||
|
assertResult(t, "4", got)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestWrite_array(t *testing.T) {
|
func TestWrite_array(t *testing.T) {
|
||||||
@@ -179,7 +238,8 @@ b:
|
|||||||
`)
|
`)
|
||||||
|
|
||||||
updated := writeMap(data, []string{"b", "0"}, "4")
|
updated := writeMap(data, []string{"b", "0"}, "4")
|
||||||
assertResult(t, "4", readMap(updated, "b", []string{"0"}))
|
got, _ := readMap(updated, "b", []string{"0"})
|
||||||
|
assertResult(t, "4", got)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestWrite_new_array_deep(t *testing.T) {
|
func TestWrite_new_array_deep(t *testing.T) {
|
||||||
@@ -192,7 +252,8 @@ b:
|
|||||||
- c: "4"`
|
- c: "4"`
|
||||||
|
|
||||||
updated := writeMap(data, []string{"b", "0", "c"}, "4")
|
updated := writeMap(data, []string{"b", "0", "c"}, "4")
|
||||||
assertResult(t, expected, yamlToString(updated))
|
got, _ := yamlToString(updated)
|
||||||
|
assertResult(t, expected, got)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestWrite_new_map_array_deep(t *testing.T) {
|
func TestWrite_new_map_array_deep(t *testing.T) {
|
||||||
@@ -202,7 +263,8 @@ b:
|
|||||||
`)
|
`)
|
||||||
|
|
||||||
updated := writeMap(data, []string{"b", "d", "0"}, "4")
|
updated := writeMap(data, []string{"b", "d", "0"}, "4")
|
||||||
assertResult(t, "4", readMap(updated, "b", []string{"d", "0"}))
|
got, _ := readMap(updated, "b", []string{"d", "0"})
|
||||||
|
assertResult(t, "4", got)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestWrite_add_to_array(t *testing.T) {
|
func TestWrite_add_to_array(t *testing.T) {
|
||||||
@@ -216,8 +278,8 @@ b:
|
|||||||
- bb`
|
- bb`
|
||||||
|
|
||||||
updated := writeMap(data, []string{"b", "1"}, "bb")
|
updated := writeMap(data, []string{"b", "1"}, "bb")
|
||||||
|
got, _ := yamlToString(updated)
|
||||||
assertResult(t, expected, yamlToString(updated))
|
assertResult(t, expected, got)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestWrite_with_no_tail(t *testing.T) {
|
func TestWrite_with_no_tail(t *testing.T) {
|
||||||
|
|||||||
@@ -1,17 +1,18 @@
|
|||||||
|
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html class="no-js">
|
<html lang="en" class="no-js">
|
||||||
<head>
|
<head>
|
||||||
|
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||||
|
<meta http-equiv="x-ua-compatible" content="ie=edge">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<link rel="shortcut icon" href="/assets/images/favicon.png">
|
<link rel="shortcut icon" href="/assets/images/favicon.png">
|
||||||
|
|
||||||
<meta name="generator" content="mkdocs-0.16.3, mkdocs-material-1.5.4">
|
<meta name="generator" content="mkdocs-0.16.3, mkdocs-material-1.10.1">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -19,10 +20,10 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
<script src="/assets/javascripts/modernizr-56ade86843.js"></script>
|
<script src="/assets/javascripts/modernizr-e826f8942a.js"></script>
|
||||||
|
|
||||||
|
|
||||||
<link rel="stylesheet" href="/assets/stylesheets/application-b1a1975878.css">
|
<link rel="stylesheet" href="/assets/stylesheets/application-a20f419c8e.css">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -60,10 +61,11 @@
|
|||||||
<nav class="md-header-nav md-grid">
|
<nav class="md-header-nav md-grid">
|
||||||
<div class="md-flex">
|
<div class="md-flex">
|
||||||
<div class="md-flex__cell md-flex__cell--shrink">
|
<div class="md-flex__cell md-flex__cell--shrink">
|
||||||
|
<a href="/" title="Yaml" class="md-header-nav__button md-logo">
|
||||||
<a href="/" title="Yaml" class="md-icon md-icon--home md-header-nav__button">
|
|
||||||
</a>
|
<i class="md-icon md-icon--home"></i>
|
||||||
|
|
||||||
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="md-flex__cell md-flex__cell--shrink">
|
<div class="md-flex__cell md-flex__cell--shrink">
|
||||||
<label class="md-icon md-icon--menu md-header-nav__button" for="drawer"></label>
|
<label class="md-icon md-icon--menu md-header-nav__button" for="drawer"></label>
|
||||||
@@ -80,17 +82,17 @@
|
|||||||
|
|
||||||
<label class="md-icon md-icon--search md-header-nav__button" for="search"></label>
|
<label class="md-icon md-icon--search md-header-nav__button" for="search"></label>
|
||||||
|
|
||||||
<div class="md-search" data-md-component="search">
|
<div class="md-search" data-md-component="search" role="dialog">
|
||||||
<div class="md-search__overlay"></div>
|
<label class="md-search__overlay" for="search"></label>
|
||||||
<div class="md-search__inner">
|
<div class="md-search__inner">
|
||||||
<form class="md-search__form" name="search">
|
<form class="md-search__form" name="search">
|
||||||
<input type="text" class="md-search__input" name="query" required placeholder="Search" accesskey="s" autocapitalize="off" autocorrect="off" autocomplete="off" spellcheck="false" data-md-component="query">
|
<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>
|
<label class="md-icon md-search__icon" for="search"></label>
|
||||||
<button type="reset" class="md-icon md-search__icon" data-md-component="reset">close</button>
|
<button type="reset" class="md-icon md-search__icon" data-md-component="reset"></button>
|
||||||
</form>
|
</form>
|
||||||
<div class="md-search__output">
|
<div class="md-search__output">
|
||||||
<div class="md-search__scrollwrap" data-md-scrollfix>
|
<div class="md-search__scrollwrap" data-md-scrollfix>
|
||||||
<div class="md-search-result" data-md-component="result">
|
<div class="md-search-result" data-md-component="result" data-md-lang-search="" data-md-lang-tokenizer="[\s\-]+">
|
||||||
<div class="md-search-result__meta" data-md-lang-result-none="No matching documents" data-md-lang-result-one="1 matching document" data-md-lang-result-other="# matching documents">
|
<div class="md-search-result__meta" data-md-lang-result-none="No matching documents" data-md-lang-result-one="1 matching document" data-md-lang-result-other="# matching documents">
|
||||||
Type to start searching
|
Type to start searching
|
||||||
</div>
|
</div>
|
||||||
@@ -102,9 +104,9 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="md-flex__cell md-flex__cell--shrink">
|
|
||||||
<div class="md-header-nav__source">
|
<div class="md-flex__cell md-flex__cell--shrink">
|
||||||
|
<div class="md-header-nav__source">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -124,9 +126,9 @@
|
|||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
</header>
|
</header>
|
||||||
@@ -143,9 +145,11 @@
|
|||||||
<div class="md-sidebar__inner">
|
<div class="md-sidebar__inner">
|
||||||
<nav class="md-nav md-nav--primary" data-md-level="0">
|
<nav class="md-nav md-nav--primary" data-md-level="0">
|
||||||
<label class="md-nav__title md-nav__title--site" for="drawer">
|
<label class="md-nav__title md-nav__title--site" for="drawer">
|
||||||
|
<div class="md-nav__button md-logo">
|
||||||
<i class="md-icon md-icon--home md-nav__button"></i>
|
|
||||||
|
<i class="md-icon md-icon--home"></i>
|
||||||
|
|
||||||
|
</div>
|
||||||
Yaml
|
Yaml
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
@@ -233,6 +237,18 @@
|
|||||||
</li>
|
</li>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="/merge/" title="Merge" class="md-nav__link">
|
||||||
|
Merge
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
@@ -286,7 +302,9 @@
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="/assets/javascripts/application-0b7df094bf.js"></script>
|
<script src="/assets/javascripts/application-f3ab9e5ff8.js"></script>
|
||||||
|
|
||||||
|
|
||||||
<script>app.initialize({url:{base:""}})</script>
|
<script>app.initialize({url:{base:""}})</script>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
1
docs/assets/javascripts/application-f3ab9e5ff8.js
Normal file
1
docs/assets/javascripts/application-f3ab9e5ff8.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=f.cursor+3;if(d=f.limit,0<=r&&r<=f.limit){for(a=r;;){if(e=f.cursor,f.in_grouping(w,97,248)){f.cursor=e;break}if(f.cursor=e,e>=f.limit)return;f.cursor++}for(;!f.out_grouping(w,97,248);){if(f.cursor>=f.limit)return;f.cursor++}(d=f.cursor)<a&&(d=a)}}function n(){var e,r;if(f.cursor>=d&&(r=f.limit_backward,f.limit_backward=d,f.ket=f.cursor,e=f.find_among_b(c,32),f.limit_backward=r,e))switch(f.bra=f.cursor,e){case 1:f.slice_del();break;case 2:f.in_grouping_b(p,97,229)&&f.slice_del()}}function t(){var e,r=f.limit-f.cursor;f.cursor>=d&&(e=f.limit_backward,f.limit_backward=d,f.ket=f.cursor,f.find_among_b(l,4)?(f.bra=f.cursor,f.limit_backward=e,f.cursor=f.limit-r,f.cursor>f.limit_backward&&(f.cursor--,f.bra=f.cursor,f.slice_del())):f.limit_backward=e)}function s(){var e,r,i,n=f.limit-f.cursor;if(f.ket=f.cursor,f.eq_s_b(2,"st")&&(f.bra=f.cursor,f.eq_s_b(2,"ig")&&f.slice_del()),f.cursor=f.limit-n,f.cursor>=d&&(r=f.limit_backward,f.limit_backward=d,f.ket=f.cursor,e=f.find_among_b(m,5),f.limit_backward=r,e))switch(f.bra=f.cursor,e){case 1:f.slice_del(),i=f.limit-f.cursor,t(),f.cursor=f.limit-i;break;case 2:f.slice_from("løs")}}function o(){var e;f.cursor>=d&&(e=f.limit_backward,f.limit_backward=d,f.ket=f.cursor,f.out_grouping_b(w,97,248)?(f.bra=f.cursor,u=f.slice_to(u),f.limit_backward=e,f.eq_v_b(u)&&f.slice_del()):f.limit_backward=e)}var a,d,u,c=[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)],l=[new r("gd",-1,-1),new r("dt",-1,-1),new r("gt",-1,-1),new r("kt",-1,-1)],m=[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)],w=[17,65,16,1,0,0,0,0,0,0,0,0,0,0,0,0,48,0,128],p=[239,254,42,3,0,0,0,0,0,0,0,0,0,0,0,0,16],f=new i;this.setCurrent=function(e){f.setCurrent(e)},this.getCurrent=function(){return f.getCurrent()},this.stem=function(){var r=f.cursor;return e(),f.limit_backward=r,f.cursor=f.limit,n(),f.cursor=f.limit,t(),f.cursor=f.limit,s(),f.cursor=f.limit,o(),!0}};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(){return 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(){function e(){var e,r=w.cursor+3;if(a=w.limit,0<=r||r<=w.limit){for(s=r;;){if(e=w.cursor,w.in_grouping(d,97,248)){w.cursor=e;break}if(e>=w.limit)return;w.cursor=e+1}for(;!w.out_grouping(d,97,248);){if(w.cursor>=w.limit)return;w.cursor++}(a=w.cursor)<s&&(a=s)}}function i(){var e,r,n;if(w.cursor>=a&&(r=w.limit_backward,w.limit_backward=a,w.ket=w.cursor,e=w.find_among_b(m,29),w.limit_backward=r,e))switch(w.bra=w.cursor,e){case 1:w.slice_del();break;case 2:n=w.limit-w.cursor,w.in_grouping_b(c,98,122)?w.slice_del():(w.cursor=w.limit-n,w.eq_s_b(1,"k")&&w.out_grouping_b(d,97,248)&&w.slice_del());break;case 3:w.slice_from("er")}}function t(){var e,r=w.limit-w.cursor;w.cursor>=a&&(e=w.limit_backward,w.limit_backward=a,w.ket=w.cursor,w.find_among_b(u,2)?(w.bra=w.cursor,w.limit_backward=e,w.cursor=w.limit-r,w.cursor>w.limit_backward&&(w.cursor--,w.bra=w.cursor,w.slice_del())):w.limit_backward=e)}function o(){var e,r;w.cursor>=a&&(r=w.limit_backward,w.limit_backward=a,w.ket=w.cursor,(e=w.find_among_b(l,11))?(w.bra=w.cursor,w.limit_backward=r,1==e&&w.slice_del()):w.limit_backward=r)}var s,a,m=[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)],u=[new r("dt",-1,-1),new r("vt",-1,-1)],l=[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)],d=[17,65,16,1,0,0,0,0,0,0,0,0,0,0,0,0,48,0,128],c=[119,125,149,1],w=new n;this.setCurrent=function(e){w.setCurrent(e)},this.getCurrent=function(){return w.getCurrent()},this.stem=function(){var r=w.cursor;return e(),w.limit_backward=r,w.cursor=w.limit,i(),w.cursor=w.limit,t(),w.cursor=w.limit,o(),!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(){function e(){var e,r=w.cursor+3;if(o=w.limit,0<=r||r<=w.limit){for(a=r;;){if(e=w.cursor,w.in_grouping(l,97,246)){w.cursor=e;break}if(w.cursor=e,w.cursor>=w.limit)return;w.cursor++}for(;!w.out_grouping(l,97,246);){if(w.cursor>=w.limit)return;w.cursor++}(o=w.cursor)<a&&(o=a)}}function t(){var e,r=w.limit_backward;if(w.cursor>=o&&(w.limit_backward=o,w.cursor=w.limit,w.ket=w.cursor,e=w.find_among_b(u,37),w.limit_backward=r,e))switch(w.bra=w.cursor,e){case 1:w.slice_del();break;case 2:w.in_grouping_b(d,98,121)&&w.slice_del()}}function i(){var e=w.limit_backward;w.cursor>=o&&(w.limit_backward=o,w.cursor=w.limit,w.find_among_b(c,7)&&(w.cursor=w.limit,w.ket=w.cursor,w.cursor>w.limit_backward&&(w.bra=--w.cursor,w.slice_del())),w.limit_backward=e)}function s(){var e,r;if(w.cursor>=o){if(r=w.limit_backward,w.limit_backward=o,w.cursor=w.limit,w.ket=w.cursor,e=w.find_among_b(m,5))switch(w.bra=w.cursor,e){case 1:w.slice_del();break;case 2:w.slice_from("lös");break;case 3:w.slice_from("full")}w.limit_backward=r}}var a,o,u=[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)],c=[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)],m=[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)],l=[17,65,16,1,0,0,0,0,0,0,0,0,0,0,0,0,24,0,32],d=[119,127,149],w=new n;this.setCurrent=function(e){w.setCurrent(e)},this.getCurrent=function(){return w.getCurrent()},this.stem=function(){var r=w.cursor;return e(),w.limit_backward=r,w.cursor=w.limit,t(),w.cursor=w.limit,i(),w.cursor=w.limit,s(),!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
File diff suppressed because one or more lines are too long
1
docs/assets/javascripts/modernizr-e826f8942a.js
Normal file
1
docs/assets/javascripts/modernizr-e826f8942a.js
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
1
docs/assets/stylesheets/application-a20f419c8e.css
Normal file
1
docs/assets/stylesheets/application-a20f419c8e.css
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -1,17 +1,18 @@
|
|||||||
|
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html class="no-js">
|
<html lang="en" class="no-js">
|
||||||
<head>
|
<head>
|
||||||
|
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||||
|
<meta http-equiv="x-ua-compatible" content="ie=edge">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<link rel="shortcut icon" href="../assets/images/favicon.png">
|
<link rel="shortcut icon" href="../assets/images/favicon.png">
|
||||||
|
|
||||||
<meta name="generator" content="mkdocs-0.16.3, mkdocs-material-1.5.4">
|
<meta name="generator" content="mkdocs-0.16.3, mkdocs-material-1.10.1">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -19,10 +20,10 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
<script src="../assets/javascripts/modernizr-56ade86843.js"></script>
|
<script src="../assets/javascripts/modernizr-e826f8942a.js"></script>
|
||||||
|
|
||||||
|
|
||||||
<link rel="stylesheet" href="../assets/stylesheets/application-b1a1975878.css">
|
<link rel="stylesheet" href="../assets/stylesheets/application-a20f419c8e.css">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -60,10 +61,11 @@
|
|||||||
<nav class="md-header-nav md-grid">
|
<nav class="md-header-nav md-grid">
|
||||||
<div class="md-flex">
|
<div class="md-flex">
|
||||||
<div class="md-flex__cell md-flex__cell--shrink">
|
<div class="md-flex__cell md-flex__cell--shrink">
|
||||||
|
<a href=".." title="Yaml" class="md-header-nav__button md-logo">
|
||||||
<a href=".." title="Yaml" class="md-icon md-icon--home md-header-nav__button">
|
|
||||||
</a>
|
<i class="md-icon md-icon--home"></i>
|
||||||
|
|
||||||
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="md-flex__cell md-flex__cell--shrink">
|
<div class="md-flex__cell md-flex__cell--shrink">
|
||||||
<label class="md-icon md-icon--menu md-header-nav__button" for="drawer"></label>
|
<label class="md-icon md-icon--menu md-header-nav__button" for="drawer"></label>
|
||||||
@@ -82,17 +84,17 @@
|
|||||||
|
|
||||||
<label class="md-icon md-icon--search md-header-nav__button" for="search"></label>
|
<label class="md-icon md-icon--search md-header-nav__button" for="search"></label>
|
||||||
|
|
||||||
<div class="md-search" data-md-component="search">
|
<div class="md-search" data-md-component="search" role="dialog">
|
||||||
<div class="md-search__overlay"></div>
|
<label class="md-search__overlay" for="search"></label>
|
||||||
<div class="md-search__inner">
|
<div class="md-search__inner">
|
||||||
<form class="md-search__form" name="search">
|
<form class="md-search__form" name="search">
|
||||||
<input type="text" class="md-search__input" name="query" required placeholder="Search" accesskey="s" autocapitalize="off" autocorrect="off" autocomplete="off" spellcheck="false" data-md-component="query">
|
<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>
|
<label class="md-icon md-search__icon" for="search"></label>
|
||||||
<button type="reset" class="md-icon md-search__icon" data-md-component="reset">close</button>
|
<button type="reset" class="md-icon md-search__icon" data-md-component="reset"></button>
|
||||||
</form>
|
</form>
|
||||||
<div class="md-search__output">
|
<div class="md-search__output">
|
||||||
<div class="md-search__scrollwrap" data-md-scrollfix>
|
<div class="md-search__scrollwrap" data-md-scrollfix>
|
||||||
<div class="md-search-result" data-md-component="result">
|
<div class="md-search-result" data-md-component="result" data-md-lang-search="" data-md-lang-tokenizer="[\s\-]+">
|
||||||
<div class="md-search-result__meta" data-md-lang-result-none="No matching documents" data-md-lang-result-one="1 matching document" data-md-lang-result-other="# matching documents">
|
<div class="md-search-result__meta" data-md-lang-result-none="No matching documents" data-md-lang-result-one="1 matching document" data-md-lang-result-other="# matching documents">
|
||||||
Type to start searching
|
Type to start searching
|
||||||
</div>
|
</div>
|
||||||
@@ -104,9 +106,9 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="md-flex__cell md-flex__cell--shrink">
|
|
||||||
<div class="md-header-nav__source">
|
<div class="md-flex__cell md-flex__cell--shrink">
|
||||||
|
<div class="md-header-nav__source">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -126,9 +128,9 @@
|
|||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
</header>
|
</header>
|
||||||
@@ -145,9 +147,11 @@
|
|||||||
<div class="md-sidebar__inner">
|
<div class="md-sidebar__inner">
|
||||||
<nav class="md-nav md-nav--primary" data-md-level="0">
|
<nav class="md-nav md-nav--primary" data-md-level="0">
|
||||||
<label class="md-nav__title md-nav__title--site" for="drawer">
|
<label class="md-nav__title md-nav__title--site" for="drawer">
|
||||||
|
<div class="md-nav__button md-logo">
|
||||||
<i class="md-icon md-icon--home md-nav__button"></i>
|
|
||||||
|
<i class="md-icon md-icon--home"></i>
|
||||||
|
|
||||||
|
</div>
|
||||||
Yaml
|
Yaml
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
@@ -274,6 +278,18 @@
|
|||||||
</li>
|
</li>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="../merge/" title="Merge" class="md-nav__link">
|
||||||
|
Merge
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
@@ -389,6 +405,20 @@ b:
|
|||||||
</a>
|
</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>
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -421,7 +451,9 @@ b:
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="../assets/javascripts/application-0b7df094bf.js"></script>
|
<script src="../assets/javascripts/application-f3ab9e5ff8.js"></script>
|
||||||
|
|
||||||
|
|
||||||
<script>app.initialize({url:{base:".."}})</script>
|
<script>app.initialize({url:{base:".."}})</script>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,17 +1,18 @@
|
|||||||
|
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html class="no-js">
|
<html lang="en" class="no-js">
|
||||||
<head>
|
<head>
|
||||||
|
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||||
|
<meta http-equiv="x-ua-compatible" content="ie=edge">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<link rel="shortcut icon" href="../assets/images/favicon.png">
|
<link rel="shortcut icon" href="../assets/images/favicon.png">
|
||||||
|
|
||||||
<meta name="generator" content="mkdocs-0.16.3, mkdocs-material-1.5.4">
|
<meta name="generator" content="mkdocs-0.16.3, mkdocs-material-1.10.1">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -19,10 +20,10 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
<script src="../assets/javascripts/modernizr-56ade86843.js"></script>
|
<script src="../assets/javascripts/modernizr-e826f8942a.js"></script>
|
||||||
|
|
||||||
|
|
||||||
<link rel="stylesheet" href="../assets/stylesheets/application-b1a1975878.css">
|
<link rel="stylesheet" href="../assets/stylesheets/application-a20f419c8e.css">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -60,10 +61,11 @@
|
|||||||
<nav class="md-header-nav md-grid">
|
<nav class="md-header-nav md-grid">
|
||||||
<div class="md-flex">
|
<div class="md-flex">
|
||||||
<div class="md-flex__cell md-flex__cell--shrink">
|
<div class="md-flex__cell md-flex__cell--shrink">
|
||||||
|
<a href=".." title="Yaml" class="md-header-nav__button md-logo">
|
||||||
<a href=".." title="Yaml" class="md-icon md-icon--home md-header-nav__button">
|
|
||||||
</a>
|
<i class="md-icon md-icon--home"></i>
|
||||||
|
|
||||||
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="md-flex__cell md-flex__cell--shrink">
|
<div class="md-flex__cell md-flex__cell--shrink">
|
||||||
<label class="md-icon md-icon--menu md-header-nav__button" for="drawer"></label>
|
<label class="md-icon md-icon--menu md-header-nav__button" for="drawer"></label>
|
||||||
@@ -82,17 +84,17 @@
|
|||||||
|
|
||||||
<label class="md-icon md-icon--search md-header-nav__button" for="search"></label>
|
<label class="md-icon md-icon--search md-header-nav__button" for="search"></label>
|
||||||
|
|
||||||
<div class="md-search" data-md-component="search">
|
<div class="md-search" data-md-component="search" role="dialog">
|
||||||
<div class="md-search__overlay"></div>
|
<label class="md-search__overlay" for="search"></label>
|
||||||
<div class="md-search__inner">
|
<div class="md-search__inner">
|
||||||
<form class="md-search__form" name="search">
|
<form class="md-search__form" name="search">
|
||||||
<input type="text" class="md-search__input" name="query" required placeholder="Search" accesskey="s" autocapitalize="off" autocorrect="off" autocomplete="off" spellcheck="false" data-md-component="query">
|
<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>
|
<label class="md-icon md-search__icon" for="search"></label>
|
||||||
<button type="reset" class="md-icon md-search__icon" data-md-component="reset">close</button>
|
<button type="reset" class="md-icon md-search__icon" data-md-component="reset"></button>
|
||||||
</form>
|
</form>
|
||||||
<div class="md-search__output">
|
<div class="md-search__output">
|
||||||
<div class="md-search__scrollwrap" data-md-scrollfix>
|
<div class="md-search__scrollwrap" data-md-scrollfix>
|
||||||
<div class="md-search-result" data-md-component="result">
|
<div class="md-search-result" data-md-component="result" data-md-lang-search="" data-md-lang-tokenizer="[\s\-]+">
|
||||||
<div class="md-search-result__meta" data-md-lang-result-none="No matching documents" data-md-lang-result-one="1 matching document" data-md-lang-result-other="# matching documents">
|
<div class="md-search-result__meta" data-md-lang-result-none="No matching documents" data-md-lang-result-one="1 matching document" data-md-lang-result-other="# matching documents">
|
||||||
Type to start searching
|
Type to start searching
|
||||||
</div>
|
</div>
|
||||||
@@ -104,9 +106,9 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="md-flex__cell md-flex__cell--shrink">
|
|
||||||
<div class="md-header-nav__source">
|
<div class="md-flex__cell md-flex__cell--shrink">
|
||||||
|
<div class="md-header-nav__source">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -126,9 +128,9 @@
|
|||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
</header>
|
</header>
|
||||||
@@ -145,9 +147,11 @@
|
|||||||
<div class="md-sidebar__inner">
|
<div class="md-sidebar__inner">
|
||||||
<nav class="md-nav md-nav--primary" data-md-level="0">
|
<nav class="md-nav md-nav--primary" data-md-level="0">
|
||||||
<label class="md-nav__title md-nav__title--site" for="drawer">
|
<label class="md-nav__title md-nav__title--site" for="drawer">
|
||||||
|
<div class="md-nav__button md-logo">
|
||||||
<i class="md-icon md-icon--home md-nav__button"></i>
|
|
||||||
|
<i class="md-icon md-icon--home"></i>
|
||||||
|
|
||||||
|
</div>
|
||||||
Yaml
|
Yaml
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
@@ -274,6 +278,18 @@
|
|||||||
</li>
|
</li>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="../merge/" title="Merge" class="md-nav__link">
|
||||||
|
Merge
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
@@ -436,7 +452,9 @@ b.e[0].name: Howdy Partner
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="../assets/javascripts/application-0b7df094bf.js"></script>
|
<script src="../assets/javascripts/application-f3ab9e5ff8.js"></script>
|
||||||
|
|
||||||
|
|
||||||
<script>app.initialize({url:{base:".."}})</script>
|
<script>app.initialize({url:{base:".."}})</script>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,17 +1,18 @@
|
|||||||
|
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html class="no-js">
|
<html lang="en" class="no-js">
|
||||||
<head>
|
<head>
|
||||||
|
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||||
|
<meta http-equiv="x-ua-compatible" content="ie=edge">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<link rel="shortcut icon" href="./assets/images/favicon.png">
|
<link rel="shortcut icon" href="./assets/images/favicon.png">
|
||||||
|
|
||||||
<meta name="generator" content="mkdocs-0.16.3, mkdocs-material-1.5.4">
|
<meta name="generator" content="mkdocs-0.16.3, mkdocs-material-1.10.1">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -19,10 +20,10 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
<script src="./assets/javascripts/modernizr-56ade86843.js"></script>
|
<script src="./assets/javascripts/modernizr-e826f8942a.js"></script>
|
||||||
|
|
||||||
|
|
||||||
<link rel="stylesheet" href="./assets/stylesheets/application-b1a1975878.css">
|
<link rel="stylesheet" href="./assets/stylesheets/application-a20f419c8e.css">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -60,10 +61,11 @@
|
|||||||
<nav class="md-header-nav md-grid">
|
<nav class="md-header-nav md-grid">
|
||||||
<div class="md-flex">
|
<div class="md-flex">
|
||||||
<div class="md-flex__cell md-flex__cell--shrink">
|
<div class="md-flex__cell md-flex__cell--shrink">
|
||||||
|
<a href="." title="Yaml" class="md-header-nav__button md-logo">
|
||||||
<a href="." title="Yaml" class="md-icon md-icon--home md-header-nav__button">
|
|
||||||
</a>
|
<i class="md-icon md-icon--home"></i>
|
||||||
|
|
||||||
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="md-flex__cell md-flex__cell--shrink">
|
<div class="md-flex__cell md-flex__cell--shrink">
|
||||||
<label class="md-icon md-icon--menu md-header-nav__button" for="drawer"></label>
|
<label class="md-icon md-icon--menu md-header-nav__button" for="drawer"></label>
|
||||||
@@ -82,17 +84,17 @@
|
|||||||
|
|
||||||
<label class="md-icon md-icon--search md-header-nav__button" for="search"></label>
|
<label class="md-icon md-icon--search md-header-nav__button" for="search"></label>
|
||||||
|
|
||||||
<div class="md-search" data-md-component="search">
|
<div class="md-search" data-md-component="search" role="dialog">
|
||||||
<div class="md-search__overlay"></div>
|
<label class="md-search__overlay" for="search"></label>
|
||||||
<div class="md-search__inner">
|
<div class="md-search__inner">
|
||||||
<form class="md-search__form" name="search">
|
<form class="md-search__form" name="search">
|
||||||
<input type="text" class="md-search__input" name="query" required placeholder="Search" accesskey="s" autocapitalize="off" autocorrect="off" autocomplete="off" spellcheck="false" data-md-component="query">
|
<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>
|
<label class="md-icon md-search__icon" for="search"></label>
|
||||||
<button type="reset" class="md-icon md-search__icon" data-md-component="reset">close</button>
|
<button type="reset" class="md-icon md-search__icon" data-md-component="reset"></button>
|
||||||
</form>
|
</form>
|
||||||
<div class="md-search__output">
|
<div class="md-search__output">
|
||||||
<div class="md-search__scrollwrap" data-md-scrollfix>
|
<div class="md-search__scrollwrap" data-md-scrollfix>
|
||||||
<div class="md-search-result" data-md-component="result">
|
<div class="md-search-result" data-md-component="result" data-md-lang-search="" data-md-lang-tokenizer="[\s\-]+">
|
||||||
<div class="md-search-result__meta" data-md-lang-result-none="No matching documents" data-md-lang-result-one="1 matching document" data-md-lang-result-other="# matching documents">
|
<div class="md-search-result__meta" data-md-lang-result-none="No matching documents" data-md-lang-result-one="1 matching document" data-md-lang-result-other="# matching documents">
|
||||||
Type to start searching
|
Type to start searching
|
||||||
</div>
|
</div>
|
||||||
@@ -104,9 +106,9 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="md-flex__cell md-flex__cell--shrink">
|
|
||||||
<div class="md-header-nav__source">
|
<div class="md-flex__cell md-flex__cell--shrink">
|
||||||
|
<div class="md-header-nav__source">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -126,9 +128,9 @@
|
|||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
</header>
|
</header>
|
||||||
@@ -145,9 +147,11 @@
|
|||||||
<div class="md-sidebar__inner">
|
<div class="md-sidebar__inner">
|
||||||
<nav class="md-nav md-nav--primary" data-md-level="0">
|
<nav class="md-nav md-nav--primary" data-md-level="0">
|
||||||
<label class="md-nav__title md-nav__title--site" for="drawer">
|
<label class="md-nav__title md-nav__title--site" for="drawer">
|
||||||
|
<div class="md-nav__button md-logo">
|
||||||
<i class="md-icon md-icon--home md-nav__button"></i>
|
|
||||||
|
<i class="md-icon md-icon--home"></i>
|
||||||
|
|
||||||
|
</div>
|
||||||
Yaml
|
Yaml
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
@@ -278,6 +282,18 @@
|
|||||||
</li>
|
</li>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="merge/" title="Merge" class="md-nav__link">
|
||||||
|
Merge
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
@@ -402,7 +418,9 @@
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="./assets/javascripts/application-0b7df094bf.js"></script>
|
<script src="./assets/javascripts/application-f3ab9e5ff8.js"></script>
|
||||||
|
|
||||||
|
|
||||||
<script>app.initialize({url:{base:"."}})</script>
|
<script>app.initialize({url:{base:"."}})</script>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
543
docs/merge/index.html
Normal file
543
docs/merge/index.html
Normal file
@@ -0,0 +1,543 @@
|
|||||||
|
|
||||||
|
<!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">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<link rel="shortcut icon" href="../assets/images/favicon.png">
|
||||||
|
|
||||||
|
<meta name="generator" content="mkdocs-0.16.3, mkdocs-material-1.10.1">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<title>Merge - Yaml</title>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<script src="../assets/javascripts/modernizr-e826f8942a.js"></script>
|
||||||
|
|
||||||
|
|
||||||
|
<link rel="stylesheet" href="../assets/stylesheets/application-a20f419c8e.css">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<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="Yaml" class="md-header-nav__button md-logo">
|
||||||
|
|
||||||
|
<i class="md-icon md-icon--home"></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">
|
||||||
|
<span class="md-flex__ellipsis md-header-nav__title">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Merge
|
||||||
|
|
||||||
|
</span>
|
||||||
|
</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" data-md-lang-search="" data-md-lang-tokenizer="[\s\-]+">
|
||||||
|
<div class="md-search-result__meta" data-md-lang-result-none="No matching documents" data-md-lang-result-one="1 matching document" data-md-lang-result-other="# matching documents">
|
||||||
|
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/yaml" 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/yaml
|
||||||
|
</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">
|
||||||
|
<div class="md-nav__button md-logo">
|
||||||
|
|
||||||
|
<i class="md-icon md-icon--home"></i>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
Yaml
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<div class="md-nav__source">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<a href="https://github.com/mikefarah/yaml" 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/yaml
|
||||||
|
</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="../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>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</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>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
</nav>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="md-content">
|
||||||
|
<article class="md-content__inner md-typeset">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<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>yaml m <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="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">yaml 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">yaml 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">yaml 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">yaml 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>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</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" title="MkDocs">MkDocs</a>
|
||||||
|
and
|
||||||
|
<a href="http://squidfunk.github.io/mkdocs-material/" title="Material for MkDocs">
|
||||||
|
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-f3ab9e5ff8.js"></script>
|
||||||
|
|
||||||
|
|
||||||
|
<script>app.initialize({url:{base:".."}})</script>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -57,7 +57,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"location": "/write/",
|
"location": "/write/",
|
||||||
"text": "yaml w \nyaml_file|json_file\n \npath\n \nnew value\n\n\n\n\n\nThis command can take a json file as input too, and will output yaml unless specified to export as json (-j)\n\n\nTo Stdout\n\n\nGiven a sample.yaml file of:\n\n\nb:\n c: 2\n\n\n\n\nthen\n\n\nyaml w sample.yaml b.c cat\n\n\n\n\nwill output:\n\n\nb:\n c: cat\n\n\n\n\nFrom STDIN\n\n\ncat sample.yaml | yaml w - b.c blah\n\n\n\n\nAdding new fields\n\n\nAny missing fields in the path will be created on the fly.\n\n\nGiven a sample.yaml file of:\n\n\nb:\n c: 2\n\n\n\n\nthen\n\n\nyaml w sample.yaml b.d[0] \nnew thing\n\n\n\n\n\nwill output:\n\n\nb:\n c: cat\n d:\n - new thing\n\n\n\n\nUpdating files in-place\n\n\nGiven a sample.yaml file of:\n\n\nb:\n c: 2\n\n\n\n\nthen\n\n\nyaml w -i sample.yaml b.c cat\n\n\n\n\nwill update the sample.yaml file so that the value of 'c' is cat.\n\n\nUpdating multiple values with a script\n\n\nGiven a sample.yaml file of:\n\n\nb:\n c: 2\n e:\n - name: Billy Bob\n\n\n\n\nand a script update_instructions.yaml of:\n\n\nb.c: 3\nb.e[0].name: Howdy Partner\n\n\n\n\nthen\n\n\nyaml w -s update_instructions.yaml sample.yaml\n\n\n\n\nwill output:\n\n\nb:\n c: 3\n e:\n - name: Howdy Partner\n\n\n\n\nAnd, of course, you can pipe the instructions in using '-':\n\n\ncat update_instructions.yaml | yaml w -s - sample.yaml\n\n\n\n\nValues starting with a hyphen (or dash)\n\n\nThe flag terminator needs to be used to stop the app from attempting to parse the subsequent arguments as flags:\n\n\nyaml w -- my.path -3\n\n\n\n\nwill output\n\n\nmy:\n path: -3",
|
"text": "yaml w \nyaml_file|json_file\n \npath\n \nnew value\n\n\n\n\n\nThis command can take a json file as input too, and will output yaml unless specified to export as json (-j)\n\n\nTo Stdout\n\n\nGiven a sample.yaml file of:\n\n\nb:\n c: 2\n\n\n\n\nthen\n\n\nyaml w sample.yaml b.c cat\n\n\n\n\nwill output:\n\n\nb:\n c: cat\n\n\n\n\nFrom STDIN\n\n\ncat sample.yaml | yaml w - b.c blah\n\n\n\n\nAdding new fields\n\n\nAny missing fields in the path will be created on the fly.\n\n\nGiven a sample.yaml file of:\n\n\nb:\n c: 2\n\n\n\n\nthen\n\n\nyaml w sample.yaml b.d[0] \nnew thing\n\n\n\n\n\nwill output:\n\n\nb:\n c: cat\n d:\n - new thing\n\n\n\n\nAppending value to an array field\n\n\nGiven a sample.yaml file of:\n\n\nb:\n c: 2\n d:\n - new thing\n - foo thing\n\n\n\n\nthen\n\n\nyaml w sample.yaml b.d[+] \nbar thing\n\n\n\n\n\nwill output:\n\n\nb:\n c: cat\n d:\n - new thing\n - foo thing\n - bar thing\n\n\n\n\nUpdating files in-place\n\n\nGiven a sample.yaml file of:\n\n\nb:\n c: 2\n\n\n\n\nthen\n\n\nyaml w -i sample.yaml b.c cat\n\n\n\n\nwill update the sample.yaml file so that the value of 'c' is cat.\n\n\nUpdating multiple values with a script\n\n\nGiven a sample.yaml file of:\n\n\nb:\n c: 2\n e:\n - name: Billy Bob\n\n\n\n\nand a script update_instructions.yaml of:\n\n\nb.c: 3\nb.e[0].name: Howdy Partner\n\n\n\n\nthen\n\n\nyaml w -s update_instructions.yaml sample.yaml\n\n\n\n\nwill output:\n\n\nb:\n c: 3\n e:\n - name: Howdy Partner\n\n\n\n\nAnd, of course, you can pipe the instructions in using '-':\n\n\ncat update_instructions.yaml | yaml w -s - sample.yaml\n\n\n\n\nValues starting with a hyphen (or dash)\n\n\nThe flag terminator needs to be used to stop the app from attempting to parse the subsequent arguments as flags:\n\n\nyaml w -- my.path -3\n\n\n\n\nwill output\n\n\nmy:\n path: -3",
|
||||||
"title": "Write/Update"
|
"title": "Write/Update"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -75,6 +75,11 @@
|
|||||||
"text": "Any missing fields in the path will be created on the fly. Given a sample.yaml file of: b:\n c: 2 then yaml w sample.yaml b.d[0] new thing will output: b:\n c: cat\n d:\n - new thing",
|
"text": "Any missing fields in the path will be created on the fly. Given a sample.yaml file of: b:\n c: 2 then yaml w sample.yaml b.d[0] new thing will output: b:\n c: cat\n d:\n - new thing",
|
||||||
"title": "Adding new fields"
|
"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 yaml w sample.yaml b.d[+] bar thing will output: b:\n c: cat\n d:\n - new thing\n - foo thing\n - bar thing",
|
||||||
|
"title": "Appending value to an array field"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"location": "/write/#updating-files-in-place",
|
"location": "/write/#updating-files-in-place",
|
||||||
"text": "Given a sample.yaml file of: b:\n c: 2 then yaml w -i sample.yaml b.c cat will update the sample.yaml file so that the value of 'c' is cat.",
|
"text": "Given a sample.yaml file of: b:\n c: 2 then yaml w -i sample.yaml b.c cat will update the sample.yaml file so that the value of 'c' is cat.",
|
||||||
@@ -119,6 +124,31 @@
|
|||||||
"location": "/convert/#json-to-yaml",
|
"location": "/convert/#json-to-yaml",
|
||||||
"text": "To read in json, just pass in a json file instead of yaml, it will just work :) e.g given a json file { a : Easy! as one two three , b :{ c :2, d :[3,4]}} then yaml r sample.json will output a: Easy! as one two three\nb:\n c: 2\n d:\n - 3\n - 4",
|
"text": "To read in json, just pass in a json file instead of yaml, it will just work :) e.g given a json file { a : Easy! as one two three , b :{ c :2, d :[3,4]}} then yaml r sample.json will output a: Easy! as one two three\nb:\n c: 2\n d:\n - 3\n - 4",
|
||||||
"title": "Json to Yaml"
|
"title": "Json to Yaml"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"location": "/merge/",
|
||||||
|
"text": "Yaml files can be merged using the 'merge' command. Each additional file merged with the first file will\nset values for any key not existing already or where the key has no value.\n\n\nyaml m \nyaml_file|json_file\n \npath\n...\n\n\n\n\nThis command can take a json file as input too, and will output yaml unless specified to export as json (-j)\n\n\nTo Stdout\n\n\nGiven a data1.yaml file of:\n\n\na: simple\nb: [1, 2]\n\n\n\n\nand data2.yaml file of:\n\n\na: other\nc:\n test: 1\n\n\n\n\nthen\n\n\nyaml m data1.yaml data2.yaml\n\n\n\n\nwill output:\n\n\na: simple\nb: [1, 2]\nc:\n test: 1\n\n\n\n\nUpdating files in-place\n\n\nGiven a data1.yaml file of:\n\n\na: simple\nb: [1, 2]\n\n\n\n\nand data2.yaml file of:\n\n\na: other\nc:\n test: 1\n\n\n\n\nthen\n\n\nyaml m -i data1.yaml data2.yaml\n\n\n\n\nwill update the data1.yaml file so that the value of 'c' is 'test: 1'.\n\n\nOverwrite values\n\n\nGiven a data1.yaml file of:\n\n\na: simple\nb: [1, 2]\n\n\n\n\nand data2.yaml file of:\n\n\na: other\nc:\n test: 1\n\n\n\n\nthen\n\n\nyaml m -x data1.yaml data2.yaml\n\n\n\n\nwill output:\n\n\na: other\nb: [1, 2]\nc:\n test: 1\n\n\n\n\nOverwrite values with arrays\n\n\nGiven a data1.yaml file of:\n\n\na: simple\nb: [1, 2]\n\n\n\n\nand data3.yaml file of:\n\n\nb: [2, 3, 4]\nc:\n test: 2\n other: true\nd: false\n\n\n\n\nthen\n\n\nyaml m -x data1.yaml data3.yaml\n\n\n\n\nwill output:\n\n\na: simple\nb: [2, 3, 4]\nc:\n test: 2\n other: true\nd: false\n\n\n\n\nNotice that 'b' does not result in the merging of the values within an array. The underlying library does not\ncurrently handle merging values within an array.",
|
||||||
|
"title": "Merge"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"location": "/merge/#to-stdout",
|
||||||
|
"text": "Given a data1.yaml file of: a: simple\nb: [1, 2] and data2.yaml file of: a: other\nc:\n test: 1 then yaml m data1.yaml data2.yaml will output: a: simple\nb: [1, 2]\nc:\n test: 1",
|
||||||
|
"title": "To Stdout"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"location": "/merge/#updating-files-in-place",
|
||||||
|
"text": "Given a data1.yaml file of: a: simple\nb: [1, 2] and data2.yaml file of: a: other\nc:\n test: 1 then yaml m -i data1.yaml data2.yaml will update the data1.yaml file so that the value of 'c' is 'test: 1'.",
|
||||||
|
"title": "Updating files in-place"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"location": "/merge/#overwrite-values",
|
||||||
|
"text": "Given a data1.yaml file of: a: simple\nb: [1, 2] and data2.yaml file of: a: other\nc:\n test: 1 then yaml m -x data1.yaml data2.yaml will output: a: other\nb: [1, 2]\nc:\n test: 1",
|
||||||
|
"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 yaml m -x data1.yaml data3.yaml will output: a: simple\nb: [2, 3, 4]\nc:\n test: 2\n other: true\nd: false Notice that 'b' does not result in the merging of the values within an array. The underlying library does not\ncurrently handle merging values within an array.",
|
||||||
|
"title": "Overwrite values with arrays"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -1,17 +1,18 @@
|
|||||||
|
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html class="no-js">
|
<html lang="en" class="no-js">
|
||||||
<head>
|
<head>
|
||||||
|
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||||
|
<meta http-equiv="x-ua-compatible" content="ie=edge">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<link rel="shortcut icon" href="../assets/images/favicon.png">
|
<link rel="shortcut icon" href="../assets/images/favicon.png">
|
||||||
|
|
||||||
<meta name="generator" content="mkdocs-0.16.3, mkdocs-material-1.5.4">
|
<meta name="generator" content="mkdocs-0.16.3, mkdocs-material-1.10.1">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -19,10 +20,10 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
<script src="../assets/javascripts/modernizr-56ade86843.js"></script>
|
<script src="../assets/javascripts/modernizr-e826f8942a.js"></script>
|
||||||
|
|
||||||
|
|
||||||
<link rel="stylesheet" href="../assets/stylesheets/application-b1a1975878.css">
|
<link rel="stylesheet" href="../assets/stylesheets/application-a20f419c8e.css">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -60,10 +61,11 @@
|
|||||||
<nav class="md-header-nav md-grid">
|
<nav class="md-header-nav md-grid">
|
||||||
<div class="md-flex">
|
<div class="md-flex">
|
||||||
<div class="md-flex__cell md-flex__cell--shrink">
|
<div class="md-flex__cell md-flex__cell--shrink">
|
||||||
|
<a href=".." title="Yaml" class="md-header-nav__button md-logo">
|
||||||
<a href=".." title="Yaml" class="md-icon md-icon--home md-header-nav__button">
|
|
||||||
</a>
|
<i class="md-icon md-icon--home"></i>
|
||||||
|
|
||||||
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="md-flex__cell md-flex__cell--shrink">
|
<div class="md-flex__cell md-flex__cell--shrink">
|
||||||
<label class="md-icon md-icon--menu md-header-nav__button" for="drawer"></label>
|
<label class="md-icon md-icon--menu md-header-nav__button" for="drawer"></label>
|
||||||
@@ -82,17 +84,17 @@
|
|||||||
|
|
||||||
<label class="md-icon md-icon--search md-header-nav__button" for="search"></label>
|
<label class="md-icon md-icon--search md-header-nav__button" for="search"></label>
|
||||||
|
|
||||||
<div class="md-search" data-md-component="search">
|
<div class="md-search" data-md-component="search" role="dialog">
|
||||||
<div class="md-search__overlay"></div>
|
<label class="md-search__overlay" for="search"></label>
|
||||||
<div class="md-search__inner">
|
<div class="md-search__inner">
|
||||||
<form class="md-search__form" name="search">
|
<form class="md-search__form" name="search">
|
||||||
<input type="text" class="md-search__input" name="query" required placeholder="Search" accesskey="s" autocapitalize="off" autocorrect="off" autocomplete="off" spellcheck="false" data-md-component="query">
|
<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>
|
<label class="md-icon md-search__icon" for="search"></label>
|
||||||
<button type="reset" class="md-icon md-search__icon" data-md-component="reset">close</button>
|
<button type="reset" class="md-icon md-search__icon" data-md-component="reset"></button>
|
||||||
</form>
|
</form>
|
||||||
<div class="md-search__output">
|
<div class="md-search__output">
|
||||||
<div class="md-search__scrollwrap" data-md-scrollfix>
|
<div class="md-search__scrollwrap" data-md-scrollfix>
|
||||||
<div class="md-search-result" data-md-component="result">
|
<div class="md-search-result" data-md-component="result" data-md-lang-search="" data-md-lang-tokenizer="[\s\-]+">
|
||||||
<div class="md-search-result__meta" data-md-lang-result-none="No matching documents" data-md-lang-result-one="1 matching document" data-md-lang-result-other="# matching documents">
|
<div class="md-search-result__meta" data-md-lang-result-none="No matching documents" data-md-lang-result-one="1 matching document" data-md-lang-result-other="# matching documents">
|
||||||
Type to start searching
|
Type to start searching
|
||||||
</div>
|
</div>
|
||||||
@@ -104,9 +106,9 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="md-flex__cell md-flex__cell--shrink">
|
|
||||||
<div class="md-header-nav__source">
|
<div class="md-flex__cell md-flex__cell--shrink">
|
||||||
|
<div class="md-header-nav__source">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -126,9 +128,9 @@
|
|||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
</header>
|
</header>
|
||||||
@@ -145,9 +147,11 @@
|
|||||||
<div class="md-sidebar__inner">
|
<div class="md-sidebar__inner">
|
||||||
<nav class="md-nav md-nav--primary" data-md-level="0">
|
<nav class="md-nav md-nav--primary" data-md-level="0">
|
||||||
<label class="md-nav__title md-nav__title--site" for="drawer">
|
<label class="md-nav__title md-nav__title--site" for="drawer">
|
||||||
|
<div class="md-nav__button md-logo">
|
||||||
<i class="md-icon md-icon--home md-nav__button"></i>
|
|
||||||
|
<i class="md-icon md-icon--home"></i>
|
||||||
|
|
||||||
|
</div>
|
||||||
Yaml
|
Yaml
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
@@ -302,6 +306,18 @@
|
|||||||
</li>
|
</li>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="../merge/" title="Merge" class="md-nav__link">
|
||||||
|
Merge
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
@@ -543,7 +559,9 @@ e.g.: given a sample file of</p>
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="../assets/javascripts/application-0b7df094bf.js"></script>
|
<script src="../assets/javascripts/application-f3ab9e5ff8.js"></script>
|
||||||
|
|
||||||
|
|
||||||
<script>app.initialize({url:{base:".."}})</script>
|
<script>app.initialize({url:{base:".."}})</script>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
<url>
|
<url>
|
||||||
<loc>/</loc>
|
<loc>/</loc>
|
||||||
<lastmod>2017-05-03</lastmod>
|
<lastmod>2017-09-24</lastmod>
|
||||||
<changefreq>daily</changefreq>
|
<changefreq>daily</changefreq>
|
||||||
</url>
|
</url>
|
||||||
|
|
||||||
@@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
<url>
|
<url>
|
||||||
<loc>/read/</loc>
|
<loc>/read/</loc>
|
||||||
<lastmod>2017-05-03</lastmod>
|
<lastmod>2017-09-24</lastmod>
|
||||||
<changefreq>daily</changefreq>
|
<changefreq>daily</changefreq>
|
||||||
</url>
|
</url>
|
||||||
|
|
||||||
@@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
<url>
|
<url>
|
||||||
<loc>/write/</loc>
|
<loc>/write/</loc>
|
||||||
<lastmod>2017-05-03</lastmod>
|
<lastmod>2017-09-24</lastmod>
|
||||||
<changefreq>daily</changefreq>
|
<changefreq>daily</changefreq>
|
||||||
</url>
|
</url>
|
||||||
|
|
||||||
@@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
<url>
|
<url>
|
||||||
<loc>/create/</loc>
|
<loc>/create/</loc>
|
||||||
<lastmod>2017-05-03</lastmod>
|
<lastmod>2017-09-24</lastmod>
|
||||||
<changefreq>daily</changefreq>
|
<changefreq>daily</changefreq>
|
||||||
</url>
|
</url>
|
||||||
|
|
||||||
@@ -36,7 +36,15 @@
|
|||||||
|
|
||||||
<url>
|
<url>
|
||||||
<loc>/convert/</loc>
|
<loc>/convert/</loc>
|
||||||
<lastmod>2017-05-03</lastmod>
|
<lastmod>2017-09-24</lastmod>
|
||||||
|
<changefreq>daily</changefreq>
|
||||||
|
</url>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<url>
|
||||||
|
<loc>/merge/</loc>
|
||||||
|
<lastmod>2017-09-24</lastmod>
|
||||||
<changefreq>daily</changefreq>
|
<changefreq>daily</changefreq>
|
||||||
</url>
|
</url>
|
||||||
|
|
||||||
|
|||||||
@@ -1,17 +1,18 @@
|
|||||||
|
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html class="no-js">
|
<html lang="en" class="no-js">
|
||||||
<head>
|
<head>
|
||||||
|
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||||
|
<meta http-equiv="x-ua-compatible" content="ie=edge">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<link rel="shortcut icon" href="../assets/images/favicon.png">
|
<link rel="shortcut icon" href="../assets/images/favicon.png">
|
||||||
|
|
||||||
<meta name="generator" content="mkdocs-0.16.3, mkdocs-material-1.5.4">
|
<meta name="generator" content="mkdocs-0.16.3, mkdocs-material-1.10.1">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -19,10 +20,10 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
<script src="../assets/javascripts/modernizr-56ade86843.js"></script>
|
<script src="../assets/javascripts/modernizr-e826f8942a.js"></script>
|
||||||
|
|
||||||
|
|
||||||
<link rel="stylesheet" href="../assets/stylesheets/application-b1a1975878.css">
|
<link rel="stylesheet" href="../assets/stylesheets/application-a20f419c8e.css">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -60,10 +61,11 @@
|
|||||||
<nav class="md-header-nav md-grid">
|
<nav class="md-header-nav md-grid">
|
||||||
<div class="md-flex">
|
<div class="md-flex">
|
||||||
<div class="md-flex__cell md-flex__cell--shrink">
|
<div class="md-flex__cell md-flex__cell--shrink">
|
||||||
|
<a href=".." title="Yaml" class="md-header-nav__button md-logo">
|
||||||
<a href=".." title="Yaml" class="md-icon md-icon--home md-header-nav__button">
|
|
||||||
</a>
|
<i class="md-icon md-icon--home"></i>
|
||||||
|
|
||||||
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="md-flex__cell md-flex__cell--shrink">
|
<div class="md-flex__cell md-flex__cell--shrink">
|
||||||
<label class="md-icon md-icon--menu md-header-nav__button" for="drawer"></label>
|
<label class="md-icon md-icon--menu md-header-nav__button" for="drawer"></label>
|
||||||
@@ -82,17 +84,17 @@
|
|||||||
|
|
||||||
<label class="md-icon md-icon--search md-header-nav__button" for="search"></label>
|
<label class="md-icon md-icon--search md-header-nav__button" for="search"></label>
|
||||||
|
|
||||||
<div class="md-search" data-md-component="search">
|
<div class="md-search" data-md-component="search" role="dialog">
|
||||||
<div class="md-search__overlay"></div>
|
<label class="md-search__overlay" for="search"></label>
|
||||||
<div class="md-search__inner">
|
<div class="md-search__inner">
|
||||||
<form class="md-search__form" name="search">
|
<form class="md-search__form" name="search">
|
||||||
<input type="text" class="md-search__input" name="query" required placeholder="Search" accesskey="s" autocapitalize="off" autocorrect="off" autocomplete="off" spellcheck="false" data-md-component="query">
|
<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>
|
<label class="md-icon md-search__icon" for="search"></label>
|
||||||
<button type="reset" class="md-icon md-search__icon" data-md-component="reset">close</button>
|
<button type="reset" class="md-icon md-search__icon" data-md-component="reset"></button>
|
||||||
</form>
|
</form>
|
||||||
<div class="md-search__output">
|
<div class="md-search__output">
|
||||||
<div class="md-search__scrollwrap" data-md-scrollfix>
|
<div class="md-search__scrollwrap" data-md-scrollfix>
|
||||||
<div class="md-search-result" data-md-component="result">
|
<div class="md-search-result" data-md-component="result" data-md-lang-search="" data-md-lang-tokenizer="[\s\-]+">
|
||||||
<div class="md-search-result__meta" data-md-lang-result-none="No matching documents" data-md-lang-result-one="1 matching document" data-md-lang-result-other="# matching documents">
|
<div class="md-search-result__meta" data-md-lang-result-none="No matching documents" data-md-lang-result-one="1 matching document" data-md-lang-result-other="# matching documents">
|
||||||
Type to start searching
|
Type to start searching
|
||||||
</div>
|
</div>
|
||||||
@@ -104,9 +106,9 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="md-flex__cell md-flex__cell--shrink">
|
|
||||||
<div class="md-header-nav__source">
|
<div class="md-flex__cell md-flex__cell--shrink">
|
||||||
|
<div class="md-header-nav__source">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -126,9 +128,9 @@
|
|||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
</header>
|
</header>
|
||||||
@@ -145,9 +147,11 @@
|
|||||||
<div class="md-sidebar__inner">
|
<div class="md-sidebar__inner">
|
||||||
<nav class="md-nav md-nav--primary" data-md-level="0">
|
<nav class="md-nav md-nav--primary" data-md-level="0">
|
||||||
<label class="md-nav__title md-nav__title--site" for="drawer">
|
<label class="md-nav__title md-nav__title--site" for="drawer">
|
||||||
|
<div class="md-nav__button md-logo">
|
||||||
<i class="md-icon md-icon--home md-nav__button"></i>
|
|
||||||
|
<i class="md-icon md-icon--home"></i>
|
||||||
|
|
||||||
|
</div>
|
||||||
Yaml
|
Yaml
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
@@ -246,6 +250,13 @@
|
|||||||
Adding new fields
|
Adding new fields
|
||||||
</a>
|
</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>
|
||||||
|
|
||||||
<li class="md-nav__item">
|
<li class="md-nav__item">
|
||||||
@@ -302,6 +313,18 @@
|
|||||||
</li>
|
</li>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<li class="md-nav__item">
|
||||||
|
<a href="../merge/" title="Merge" class="md-nav__link">
|
||||||
|
Merge
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
@@ -339,6 +362,13 @@
|
|||||||
Adding new fields
|
Adding new fields
|
||||||
</a>
|
</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>
|
||||||
|
|
||||||
<li class="md-nav__item">
|
<li class="md-nav__item">
|
||||||
@@ -420,6 +450,28 @@
|
|||||||
- new thing
|
- new thing
|
||||||
</code></pre>
|
</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">yaml 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>
|
||||||
|
|
||||||
<h3 id="updating-files-in-place">Updating files in-place<a class="headerlink" href="#updating-files-in-place" title="Permanent link">¶</a></h3>
|
<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>
|
<p>Given a sample.yaml file of:</p>
|
||||||
<pre><code class="yaml">b:
|
<pre><code class="yaml">b:
|
||||||
@@ -547,7 +599,9 @@ b.e[0].name: Howdy Partner
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="../assets/javascripts/application-0b7df094bf.js"></script>
|
<script src="../assets/javascripts/application-f3ab9e5ff8.js"></script>
|
||||||
|
|
||||||
|
|
||||||
<script>app.initialize({url:{base:".."}})</script>
|
<script>app.initialize({url:{base:".."}})</script>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
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]
|
||||||
3
examples/data2.yaml
Normal file
3
examples/data2.yaml
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
a: other
|
||||||
|
c:
|
||||||
|
test: 1
|
||||||
5
examples/data3.yaml
Normal file
5
examples/data3.yaml
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
b: [2, 3, 4]
|
||||||
|
c:
|
||||||
|
test: 2
|
||||||
|
other: true
|
||||||
|
d: false
|
||||||
@@ -2,15 +2,18 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"gopkg.in/yaml.v2"
|
"fmt"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
yaml "gopkg.in/yaml.v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
func jsonToString(context interface{}) string {
|
func jsonToString(context interface{}) (string, error) {
|
||||||
out, err := json.Marshal(toJSON(context))
|
out, err := json.Marshal(toJSON(context))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
die("error printing yaml as json: ", err)
|
return "", fmt.Errorf("error printing yaml as json: %v", err)
|
||||||
}
|
}
|
||||||
return string(out)
|
return string(out), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func toJSON(context interface{}) interface{} {
|
func toJSON(context interface{}) interface{} {
|
||||||
@@ -26,7 +29,13 @@ func toJSON(context interface{}) interface{} {
|
|||||||
oldMap := context.(yaml.MapSlice)
|
oldMap := context.(yaml.MapSlice)
|
||||||
newMap := make(map[string]interface{})
|
newMap := make(map[string]interface{})
|
||||||
for _, entry := range oldMap {
|
for _, entry := range oldMap {
|
||||||
newMap[entry.Key.(string)] = toJSON(entry.Value)
|
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
|
return newMap
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -10,7 +10,28 @@ func TestJsonToString(t *testing.T) {
|
|||||||
b:
|
b:
|
||||||
c: 2
|
c: 2
|
||||||
`)
|
`)
|
||||||
assertResult(t, "{\"b\":{\"c\":2}}", jsonToString(data))
|
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) {
|
func TestJsonToString_withArray(t *testing.T) {
|
||||||
@@ -20,5 +41,6 @@ b:
|
|||||||
- item: one
|
- item: one
|
||||||
- item: two
|
- item: two
|
||||||
`)
|
`)
|
||||||
assertResult(t, "{\"b\":[{\"item\":\"one\"},{\"item\":\"two\"}]}", jsonToString(data))
|
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 (
|
||||||
|
"github.com/imdario/mergo"
|
||||||
|
)
|
||||||
|
|
||||||
|
func merge(dst, src interface{}, overwrite bool) error {
|
||||||
|
if overwrite {
|
||||||
|
return mergo.MergeWithOverwrite(dst, src)
|
||||||
|
}
|
||||||
|
return mergo.Merge(dst, src)
|
||||||
|
}
|
||||||
30
merge_test.go
Normal file
30
merge_test.go
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
yaml "gopkg.in/yaml.v2"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestMerge(t *testing.T) {
|
||||||
|
result, _ := mergeYaml([]string{"examples/data1.yaml", "examples/data2.yaml", "examples/data3.yaml"})
|
||||||
|
expected := yaml.MapSlice{
|
||||||
|
yaml.MapItem{Key: "a", Value: "simple"},
|
||||||
|
yaml.MapItem{Key: "b", Value: []interface{}{1, 2}},
|
||||||
|
yaml.MapItem{Key: "c", Value: yaml.MapSlice{yaml.MapItem{Key: "other", Value: true}, yaml.MapItem{Key: "test", Value: 1}}},
|
||||||
|
yaml.MapItem{Key: "d", Value: false},
|
||||||
|
}
|
||||||
|
assertResultComplex(t, expected, result)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestMergeWithOverwrite(t *testing.T) {
|
||||||
|
overwriteFlag = true
|
||||||
|
result, _ := mergeYaml([]string{"examples/data1.yaml", "examples/data2.yaml", "examples/data3.yaml"})
|
||||||
|
expected := yaml.MapSlice{
|
||||||
|
yaml.MapItem{Key: "a", Value: "other"},
|
||||||
|
yaml.MapItem{Key: "b", Value: []interface{}{2, 3, 4}},
|
||||||
|
yaml.MapItem{Key: "c", Value: yaml.MapSlice{yaml.MapItem{Key: "other", Value: true}, yaml.MapItem{Key: "test", Value: 2}}},
|
||||||
|
yaml.MapItem{Key: "d", Value: false},
|
||||||
|
}
|
||||||
|
assertResultComplex(t, expected, result)
|
||||||
|
}
|
||||||
@@ -8,6 +8,7 @@ pages:
|
|||||||
- Write/Update: write.md
|
- Write/Update: write.md
|
||||||
- Create: create.md
|
- Create: create.md
|
||||||
- Convert: convert.md
|
- Convert: convert.md
|
||||||
|
- Merge: merge.md
|
||||||
repo_name: 'mikefarah/yaml'
|
repo_name: 'mikefarah/yaml'
|
||||||
repo_url: 'https://github.com/mikefarah/yaml'
|
repo_url: 'https://github.com/mikefarah/yaml'
|
||||||
|
|
||||||
|
|||||||
104
mkdocs/merge.md
Normal file
104
mkdocs/merge.md
Normal file
@@ -0,0 +1,104 @@
|
|||||||
|
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.
|
||||||
|
|
||||||
|
```
|
||||||
|
yaml m <yaml_file|json_file> <path>...
|
||||||
|
```
|
||||||
|
{!snippets/works_with_json.md!}
|
||||||
|
|
||||||
|
### 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
|
||||||
|
yaml 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
|
||||||
|
yaml 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
|
||||||
|
yaml 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
|
||||||
|
yaml 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.
|
||||||
@@ -44,6 +44,29 @@ b:
|
|||||||
- new thing
|
- 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
|
||||||
|
yaml w sample.yaml b.d[+] "bar thing"
|
||||||
|
```
|
||||||
|
will output:
|
||||||
|
```yaml
|
||||||
|
b:
|
||||||
|
c: cat
|
||||||
|
d:
|
||||||
|
- new thing
|
||||||
|
- foo thing
|
||||||
|
- bar thing
|
||||||
|
```
|
||||||
|
|
||||||
### Updating files in-place
|
### Updating files in-place
|
||||||
Given a sample.yaml file of:
|
Given a sample.yaml file of:
|
||||||
```yaml
|
```yaml
|
||||||
|
|||||||
@@ -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,9 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
gofmt -w .
|
|
||||||
golint
|
|
||||||
./ci.sh
|
|
||||||
|
|
||||||
go install
|
|
||||||
@@ -2,14 +2,10 @@
|
|||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
go test
|
|
||||||
go build
|
|
||||||
|
|
||||||
# acceptance test
|
# acceptance test
|
||||||
X=$(./yaml w sample.yaml b.c 3 | ./yaml r - b.c)
|
X=$(./bin/yaml w ./examples/sample.yaml b.c 3 | ./bin/yaml r - b.c)
|
||||||
|
|
||||||
if [ $X != 3 ]
|
if [[ $X != 3 ]]; then
|
||||||
then
|
|
||||||
echo "Failed acceptance test: expected 2 but was $X"
|
echo "Failed acceptance test: expected 2 but was $X"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
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
|
||||||
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 {} \;
|
||||||
40
scripts/publish.sh
Executable file
40
scripts/publish.sh
Executable file
@@ -0,0 +1,40 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
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="yaml"
|
||||||
|
|
||||||
|
release() {
|
||||||
|
mapfile -t logs < <(git log --pretty=oneline --abbrev-commit "${PREVIOUS}".."${CURRENT}")
|
||||||
|
description="$(printf '%s\n' "${logs[@]}")"
|
||||||
|
github-release release \
|
||||||
|
--user "$OWNER" \
|
||||||
|
--repo "$REPO" \
|
||||||
|
--tag "$CURRENT" \
|
||||||
|
--description "$description" ||
|
||||||
|
github-release edit \
|
||||||
|
--user "$OWNER" \
|
||||||
|
--repo "$REPO" \
|
||||||
|
--tag "$CURRENT" \
|
||||||
|
--description "$description"
|
||||||
|
}
|
||||||
|
|
||||||
|
upload() {
|
||||||
|
mapfile -t files < <(find ./build -mindepth 1 -maxdepth 1)
|
||||||
|
for file in "${files[@]}"; do
|
||||||
|
BINARY=$(basename "${file}")
|
||||||
|
echo "--> ${BINARY}"
|
||||||
|
github-release upload \
|
||||||
|
--user "$OWNER" \
|
||||||
|
--repo "$REPO" \
|
||||||
|
--tag "$CURRENT" \
|
||||||
|
--name "${BINARY}" \
|
||||||
|
--file "$file"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
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')
|
||||||
9
scripts/vendor.sh
Executable file
9
scripts/vendor.sh
Executable file
@@ -0,0 +1,9 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
govendor fetch github.com/op/go-logging
|
||||||
|
govendor fetch github.com/spf13/cobra
|
||||||
|
govendor fetch gopkg.in/yaml.v2
|
||||||
|
govendor fetch github.com/imdario/mergo
|
||||||
|
govendor sync
|
||||||
@@ -3,6 +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
|
||||||
|
|
||||||
rm build/*
|
gox -ldflags "${LDFLAGS}" -output="build/{{.Dir}}_{{.OS}}_{{.Arch}}"
|
||||||
gox -output="build/{{.Dir}}_{{.OS}}_{{.Arch}}"
|
|
||||||
|
|
||||||
@@ -1,17 +1,40 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"gopkg.in/yaml.v2"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
|
"reflect"
|
||||||
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
yaml "gopkg.in/yaml.v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
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 {
|
func parseData(rawData string) yaml.MapSlice {
|
||||||
var parsedData yaml.MapSlice
|
var parsedData yaml.MapSlice
|
||||||
err := yaml.Unmarshal([]byte(rawData), &parsedData)
|
err := yaml.Unmarshal([]byte(rawData), &parsedData)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("Error parsing yaml: %v", err)
|
fmt.Printf("Error parsing yaml: %v\n", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
return parsedData
|
return parsedData
|
||||||
@@ -23,6 +46,12 @@ func assertResult(t *testing.T, expectedValue interface{}, actualValue interface
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func assertResultComplex(t *testing.T, expectedValue interface{}, actualValue interface{}) {
|
||||||
|
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{}) {
|
func assertResultWithContext(t *testing.T, expectedValue interface{}, actualValue interface{}, context interface{}) {
|
||||||
|
|
||||||
if expectedValue != actualValue {
|
if expectedValue != actualValue {
|
||||||
@@ -30,3 +59,22 @@ func assertResultWithContext(t *testing.T, expectedValue interface{}, actualValu
|
|||||||
t.Error(": expected <", expectedValue, "> but got <", actualValue, ">")
|
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)
|
||||||
|
}
|
||||||
|
|||||||
39
vendor/vendor.json
vendored
39
vendor/vendor.json
vendored
@@ -1,6 +1,43 @@
|
|||||||
{
|
{
|
||||||
"comment": "",
|
"comment": "",
|
||||||
"ignore": "test",
|
"ignore": "test",
|
||||||
"package": [],
|
"package": [
|
||||||
|
{
|
||||||
|
"checksumSHA1": "66lykxpWgSmQodnhkADqn6tnroQ=",
|
||||||
|
"path": "github.com/imdario/mergo",
|
||||||
|
"revision": "e3000cb3d28c72b837601cac94debd91032d19fe",
|
||||||
|
"revisionTime": "2017-06-20T10:47:01Z"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"checksumSHA1": "40vJyUB4ezQSn/NSadsKEOrudMc=",
|
||||||
|
"path": "github.com/inconshreveable/mousetrap",
|
||||||
|
"revision": "76626ae9c91c4f2a10f34cad8ce83ea42c93bb75",
|
||||||
|
"revisionTime": "2014-10-17T20:07:13Z"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"checksumSHA1": "BoXdUBWB8UnSlFlbnuTQaPqfCGk=",
|
||||||
|
"path": "github.com/op/go-logging",
|
||||||
|
"revision": "970db520ece77730c7e4724c61121037378659d9",
|
||||||
|
"revisionTime": "2016-03-15T20:05:05Z"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"checksumSHA1": "xPKgXygsORkmXnLdtFaFmipYKaA=",
|
||||||
|
"path": "github.com/spf13/cobra",
|
||||||
|
"revision": "b78744579491c1ceeaaa3b40205e56b0591b93a3",
|
||||||
|
"revisionTime": "2017-09-05T17:20:51Z"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"checksumSHA1": "Q52Y7t0lEtk/wcDn5q7tS7B+jqs=",
|
||||||
|
"path": "github.com/spf13/pflag",
|
||||||
|
"revision": "7aff26db30c1be810f9de5038ec5ef96ac41fd7c",
|
||||||
|
"revisionTime": "2017-08-24T17:57:12Z"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"checksumSHA1": "RDJpJQwkF012L6m/2BJizyOksNw=",
|
||||||
|
"path": "gopkg.in/yaml.v2",
|
||||||
|
"revision": "eb3733d160e74a9c7e442f435eb3bea458e1d19f",
|
||||||
|
"revisionTime": "2017-08-12T16:00:11Z"
|
||||||
|
}
|
||||||
|
],
|
||||||
"rootPath": "github.com/mikefarah/yaml"
|
"rootPath": "github.com/mikefarah/yaml"
|
||||||
}
|
}
|
||||||
|
|||||||
52
version.go
Normal file
52
version.go
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
// The git commit that was compiled. This will be filled in by the compiler.
|
||||||
|
var (
|
||||||
|
GitCommit string
|
||||||
|
GitDescribe string
|
||||||
|
|
||||||
|
// Version is main version number that is being run at the moment.
|
||||||
|
Version = "1.13.0"
|
||||||
|
|
||||||
|
// VersionPrerelease is a pre-release marker for the version. If this is "" (empty string)
|
||||||
|
// then it means that it is a final release. Otherwise, this is a pre-release
|
||||||
|
// such as "dev" (in development), "beta", "rc1", etc.
|
||||||
|
VersionPrerelease = ""
|
||||||
|
)
|
||||||
|
|
||||||
|
// ProductName is the name of the product
|
||||||
|
const ProductName = "yaml"
|
||||||
|
|
||||||
|
// GetVersionDisplay composes the parts of the version in a way that's suitable
|
||||||
|
// for displaying to humans.
|
||||||
|
func GetVersionDisplay() string {
|
||||||
|
return fmt.Sprintf("%s version %s\n", ProductName, getHumanVersion())
|
||||||
|
}
|
||||||
|
|
||||||
|
func getHumanVersion() string {
|
||||||
|
version := Version
|
||||||
|
if GitDescribe != "" {
|
||||||
|
version = GitDescribe
|
||||||
|
}
|
||||||
|
|
||||||
|
release := VersionPrerelease
|
||||||
|
if GitDescribe == "" && release == "" {
|
||||||
|
release = "dev"
|
||||||
|
}
|
||||||
|
if release != "" {
|
||||||
|
if !strings.Contains(version, release) {
|
||||||
|
version += fmt.Sprintf("-%s", release)
|
||||||
|
}
|
||||||
|
if GitCommit != "" {
|
||||||
|
version += fmt.Sprintf(" (%s)", GitCommit)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Strip off any single quotes added by the git information.
|
||||||
|
return strings.Replace(version, "'", "", -1)
|
||||||
|
}
|
||||||
46
version_test.go
Normal file
46
version_test.go
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import "testing"
|
||||||
|
|
||||||
|
func TestGetVersionDisplay(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
want string
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "Display Version",
|
||||||
|
want: ProductName + " version " + Version + "-dev\n",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
for _, tt := range tests {
|
||||||
|
if got := GetVersionDisplay(); got != tt.want {
|
||||||
|
t.Errorf("%q. GetVersionDisplay() = %v, want %v", tt.name, got, tt.want)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func Test_getHumanVersion(t *testing.T) {
|
||||||
|
GitDescribe = "e42813d"
|
||||||
|
GitCommit = "e42813d+CHANGES"
|
||||||
|
var wanted string
|
||||||
|
if VersionPrerelease == "" {
|
||||||
|
wanted = GitDescribe
|
||||||
|
} else {
|
||||||
|
wanted = "e42813d-" + VersionPrerelease + " (e42813d+CHANGES)"
|
||||||
|
}
|
||||||
|
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
want string
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "Git Variables defined",
|
||||||
|
want: wanted,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
for _, tt := range tests {
|
||||||
|
if got := getHumanVersion(); got != tt.want {
|
||||||
|
t.Errorf("%q. getHumanVersion() = %v, want %v", tt.name, got, tt.want)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
330
yaml.go
330
yaml.go
@@ -1,43 +1,73 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/op/go-logging"
|
|
||||||
"github.com/spf13/cobra"
|
|
||||||
"gopkg.in/yaml.v2"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
logging "github.com/op/go-logging"
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
yaml "gopkg.in/yaml.v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
var trimOutput = true
|
var trimOutput = true
|
||||||
var writeInplace = false
|
var writeInplace = false
|
||||||
var writeScript = ""
|
var writeScript = ""
|
||||||
var inputJSON = false
|
|
||||||
var outputToJSON = false
|
var outputToJSON = false
|
||||||
|
var overwriteFlag = false
|
||||||
var verbose = false
|
var verbose = false
|
||||||
|
var version = false
|
||||||
var log = logging.MustGetLogger("yaml")
|
var log = logging.MustGetLogger("yaml")
|
||||||
var format = logging.MustStringFormatter(
|
|
||||||
`%{color}%{time:15:04:05} %{shortfunc} [%{level:.4s}]%{color:reset} %{message}`,
|
|
||||||
)
|
|
||||||
var backend = logging.AddModuleLevel(
|
|
||||||
logging.NewBackendFormatter(logging.NewLogBackend(os.Stderr, "", 0), format))
|
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
backend.SetLevel(logging.ERROR, "")
|
cmd := newCommandCLI()
|
||||||
logging.SetBackend(backend)
|
if err := cmd.Execute(); err != nil {
|
||||||
|
fmt.Println(err.Error())
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var cmdRead = createReadCmd()
|
func newCommandCLI() *cobra.Command {
|
||||||
var cmdWrite = createWriteCmd()
|
var rootCmd = &cobra.Command{
|
||||||
var cmdNew = createNewCmd()
|
Use: "yaml",
|
||||||
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
|
if version {
|
||||||
|
cmd.Print(GetVersionDisplay())
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
cmd.Println(cmd.UsageString())
|
||||||
|
|
||||||
|
return nil
|
||||||
|
},
|
||||||
|
PersistentPreRun: func(cmd *cobra.Command, args []string) {
|
||||||
|
var format = logging.MustStringFormatter(
|
||||||
|
`%{color}%{time:15:04:05} %{shortfunc} [%{level:.4s}]%{color:reset} %{message}`,
|
||||||
|
)
|
||||||
|
var backend = logging.AddModuleLevel(
|
||||||
|
logging.NewBackendFormatter(logging.NewLogBackend(os.Stderr, "", 0), format))
|
||||||
|
|
||||||
|
if verbose {
|
||||||
|
backend.SetLevel(logging.DEBUG, "")
|
||||||
|
} else {
|
||||||
|
backend.SetLevel(logging.ERROR, "")
|
||||||
|
}
|
||||||
|
|
||||||
|
logging.SetBackend(backend)
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
var rootCmd = &cobra.Command{Use: "yaml"}
|
|
||||||
rootCmd.PersistentFlags().BoolVarP(&trimOutput, "trim", "t", true, "trim yaml output")
|
rootCmd.PersistentFlags().BoolVarP(&trimOutput, "trim", "t", true, "trim yaml output")
|
||||||
rootCmd.PersistentFlags().BoolVarP(&outputToJSON, "tojson", "j", false, "output as json")
|
rootCmd.PersistentFlags().BoolVarP(&outputToJSON, "tojson", "j", false, "output as json")
|
||||||
rootCmd.PersistentFlags().BoolVarP(&verbose, "verbose", "v", false, "verbose mode")
|
rootCmd.PersistentFlags().BoolVarP(&verbose, "verbose", "v", false, "verbose mode")
|
||||||
rootCmd.AddCommand(cmdRead, cmdWrite, cmdNew)
|
rootCmd.Flags().BoolVarP(&version, "version", "V", false, "Print version information and quit")
|
||||||
rootCmd.Execute()
|
|
||||||
|
rootCmd.AddCommand(createReadCmd(), createWriteCmd(), createNewCmd(), createMergeCmd())
|
||||||
|
rootCmd.SetOutput(os.Stdout)
|
||||||
|
|
||||||
|
return rootCmd
|
||||||
}
|
}
|
||||||
|
|
||||||
func createReadCmd() *cobra.Command {
|
func createReadCmd() *cobra.Command {
|
||||||
@@ -53,7 +83,7 @@ yaml r things.yaml a.array[0].blah
|
|||||||
yaml r things.yaml a.array[*].blah
|
yaml r things.yaml a.array[*].blah
|
||||||
`,
|
`,
|
||||||
Long: "Outputs the value of the given path in the yaml file to STDOUT",
|
Long: "Outputs the value of the given path in the yaml file to STDOUT",
|
||||||
Run: readProperty,
|
RunE: readProperty,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,10 +98,14 @@ yaml write --inplace things.yaml a.b.c cat
|
|||||||
yaml w -i things.yaml a.b.c cat
|
yaml w -i things.yaml a.b.c cat
|
||||||
yaml w --script update_script.yaml things.yaml
|
yaml w --script update_script.yaml things.yaml
|
||||||
yaml w -i -s update_script.yaml things.yaml
|
yaml w -i -s update_script.yaml things.yaml
|
||||||
|
yaml w things.yaml a.b.d[+] foo
|
||||||
|
yaml w things.yaml a.b.d[+] foo
|
||||||
`,
|
`,
|
||||||
Long: `Updates the yaml file w.r.t the given path and value.
|
Long: `Updates the yaml file w.r.t the given path and value.
|
||||||
Outputs to STDOUT unless the inplace flag is used, in which case the file is updated instead.
|
Outputs to STDOUT unless the inplace flag is used, in which case the file is updated instead.
|
||||||
|
|
||||||
|
Append value to array adds the value to the end of array.
|
||||||
|
|
||||||
Update Scripts:
|
Update Scripts:
|
||||||
Note that you can give an update script to perform more sophisticated updated. Update script
|
Note that you can give an update script to perform more sophisticated updated. Update script
|
||||||
format is a yaml map where the key is the path and the value is..well the value. e.g.:
|
format is a yaml map where the key is the path and the value is..well the value. e.g.:
|
||||||
@@ -80,7 +114,7 @@ a.b.c: true,
|
|||||||
a.b.e:
|
a.b.e:
|
||||||
- name: bob
|
- name: bob
|
||||||
`,
|
`,
|
||||||
Run: writeProperty,
|
RunE: writeProperty,
|
||||||
}
|
}
|
||||||
cmdWrite.PersistentFlags().BoolVarP(&writeInplace, "inplace", "i", false, "update the yaml file inplace")
|
cmdWrite.PersistentFlags().BoolVarP(&writeInplace, "inplace", "i", false, "update the yaml file inplace")
|
||||||
cmdWrite.PersistentFlags().StringVarP(&writeScript, "script", "s", "", "yaml script for updating yaml")
|
cmdWrite.PersistentFlags().StringVarP(&writeScript, "script", "s", "", "yaml script for updating yaml")
|
||||||
@@ -103,58 +137,142 @@ Outputs to STDOUT
|
|||||||
Create Scripts:
|
Create Scripts:
|
||||||
Note that you can give a create script to perform more sophisticated yaml. This follows the same format as the update script.
|
Note that you can give a create script to perform more sophisticated yaml. This follows the same format as the update script.
|
||||||
`,
|
`,
|
||||||
Run: newProperty,
|
RunE: newProperty,
|
||||||
}
|
}
|
||||||
cmdNew.PersistentFlags().StringVarP(&writeScript, "script", "s", "", "yaml script for updating yaml")
|
cmdNew.PersistentFlags().StringVarP(&writeScript, "script", "s", "", "yaml script for updating yaml")
|
||||||
return cmdNew
|
return cmdNew
|
||||||
}
|
}
|
||||||
|
|
||||||
func readProperty(cmd *cobra.Command, args []string) {
|
func createMergeCmd() *cobra.Command {
|
||||||
if verbose {
|
var cmdMerge = &cobra.Command{
|
||||||
backend.SetLevel(logging.DEBUG, "")
|
Use: "merge [initial_yaml_file] [additional_yaml_file]...",
|
||||||
|
Aliases: []string{"m"},
|
||||||
|
Short: "yaml m [--inplace/-i] [--overwrite/-x] sample.yaml sample2.yaml",
|
||||||
|
Example: `
|
||||||
|
yaml merge things.yaml other.yaml
|
||||||
|
yaml merge --inplace things.yaml other.yaml
|
||||||
|
yaml m -i things.yaml other.yaml
|
||||||
|
yaml m --overwrite things.yaml other.yaml
|
||||||
|
yaml m -i -x things.yaml other.yaml
|
||||||
|
`,
|
||||||
|
Long: `Updates the yaml file by adding/updating the path(s) and value(s) from additional yaml file(s).
|
||||||
|
Outputs to STDOUT unless the inplace flag is used, in which case the file is updated instead.
|
||||||
|
|
||||||
|
If overwrite flag is set then existing values will be overwritten using the values from each additional yaml file.
|
||||||
|
`,
|
||||||
|
RunE: mergeProperties,
|
||||||
}
|
}
|
||||||
print(read(args))
|
cmdMerge.PersistentFlags().BoolVarP(&writeInplace, "inplace", "i", false, "update the yaml file inplace")
|
||||||
|
cmdMerge.PersistentFlags().BoolVarP(&overwriteFlag, "overwrite", "x", false, "update the yaml file by overwriting existing values")
|
||||||
|
return cmdMerge
|
||||||
}
|
}
|
||||||
|
|
||||||
func read(args []string) interface{} {
|
func readProperty(cmd *cobra.Command, args []string) error {
|
||||||
|
data, err := read(args)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
dataStr, err := toString(data)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
cmd.Println(dataStr)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func read(args []string) (interface{}, error) {
|
||||||
var parsedData yaml.MapSlice
|
var parsedData yaml.MapSlice
|
||||||
var path = ""
|
var path = ""
|
||||||
if len(args) > 1 {
|
|
||||||
|
if len(args) < 1 {
|
||||||
|
return nil, errors.New("Must provide filename")
|
||||||
|
} else if len(args) > 1 {
|
||||||
path = args[1]
|
path = args[1]
|
||||||
}
|
}
|
||||||
err := readData(args[0], &parsedData, inputJSON)
|
|
||||||
if err != nil {
|
if err := readData(args[0], &parsedData); err != nil {
|
||||||
var generalData interface{}
|
var generalData interface{}
|
||||||
readDataOrDie(args[0], &generalData, inputJSON)
|
if err = readData(args[0], &generalData); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
item := yaml.MapItem{Key: "thing", Value: generalData}
|
item := yaml.MapItem{Key: "thing", Value: generalData}
|
||||||
parsedData = yaml.MapSlice{item}
|
parsedData = yaml.MapSlice{item}
|
||||||
path = "thing." + path
|
path = "thing." + path
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if parsedData != nil && parsedData[0].Key == nil {
|
||||||
|
var interfaceData []map[interface{}]interface{}
|
||||||
|
if err := readData(args[0], &interfaceData); err == nil {
|
||||||
|
var listMap []yaml.MapSlice
|
||||||
|
for _, item := range interfaceData {
|
||||||
|
listMap = append(listMap, mapToMapSlice(item))
|
||||||
|
}
|
||||||
|
return readYamlArray(listMap, path)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if path == "" {
|
if path == "" {
|
||||||
return parsedData
|
return parsedData, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var paths = parsePath(path)
|
var paths = parsePath(path)
|
||||||
|
|
||||||
return readMap(parsedData, paths[0], paths[1:len(paths)])
|
return readMap(parsedData, paths[0], paths[1:])
|
||||||
}
|
}
|
||||||
|
|
||||||
func newProperty(cmd *cobra.Command, args []string) {
|
func readYamlArray(listMap []yaml.MapSlice, path string) (interface{}, error) {
|
||||||
if verbose {
|
if path == "" {
|
||||||
backend.SetLevel(logging.DEBUG, "")
|
return listMap, nil
|
||||||
}
|
}
|
||||||
updatedData := newYaml(args)
|
|
||||||
print(updatedData)
|
var paths = parsePath(path)
|
||||||
|
|
||||||
|
if paths[0] == "*" {
|
||||||
|
if len(paths[1:]) == 0 {
|
||||||
|
return listMap, nil
|
||||||
|
}
|
||||||
|
var results []interface{}
|
||||||
|
for _, m := range listMap {
|
||||||
|
value, err := readMap(m, paths[1], paths[2:])
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
results = append(results, value)
|
||||||
|
}
|
||||||
|
return results, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
index, err := strconv.ParseInt(paths[0], 10, 64)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("Error accessing array: %v", err)
|
||||||
|
}
|
||||||
|
if len(paths[1:]) == 0 {
|
||||||
|
return listMap[index], nil
|
||||||
|
}
|
||||||
|
return readMap(listMap[index], paths[1], paths[2:])
|
||||||
}
|
}
|
||||||
|
|
||||||
func newYaml(args []string) interface{} {
|
func newProperty(cmd *cobra.Command, args []string) error {
|
||||||
|
updatedData, err := newYaml(args)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
dataStr, err := toString(updatedData)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
cmd.Println(dataStr)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func newYaml(args []string) (interface{}, error) {
|
||||||
var writeCommands yaml.MapSlice
|
var writeCommands yaml.MapSlice
|
||||||
if writeScript != "" {
|
if writeScript != "" {
|
||||||
readDataOrDie(writeScript, &writeCommands, false)
|
if err := readData(writeScript, &writeCommands); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
} else if len(args) < 2 {
|
} else if len(args) < 2 {
|
||||||
die("Must provide <path_to_update> <value>")
|
return nil, errors.New("Must provide <path_to_update> <value>")
|
||||||
} else {
|
} else {
|
||||||
writeCommands = make(yaml.MapSlice, 1)
|
writeCommands = make(yaml.MapSlice, 1)
|
||||||
writeCommands[0] = yaml.MapItem{Key: args[0], Value: parseValue(args[1])}
|
writeCommands[0] = yaml.MapItem{Key: args[0], Value: parseValue(args[1])}
|
||||||
@@ -174,19 +292,59 @@ func newYaml(args []string) interface{} {
|
|||||||
return updateParsedData(parsedData, writeCommands, prependCommand)
|
return updateParsedData(parsedData, writeCommands, prependCommand)
|
||||||
}
|
}
|
||||||
|
|
||||||
func writeProperty(cmd *cobra.Command, args []string) {
|
func writeProperty(cmd *cobra.Command, args []string) error {
|
||||||
if verbose {
|
updatedData, err := updateYaml(args)
|
||||||
backend.SetLevel(logging.DEBUG, "")
|
if err != nil {
|
||||||
}
|
return err
|
||||||
updatedData := updateYaml(args)
|
|
||||||
if writeInplace {
|
|
||||||
ioutil.WriteFile(args[0], []byte(yamlToString(updatedData)), 0644)
|
|
||||||
} else {
|
|
||||||
print(updatedData)
|
|
||||||
}
|
}
|
||||||
|
return write(cmd, args[0], updatedData)
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateParsedData(parsedData yaml.MapSlice, writeCommands yaml.MapSlice, prependCommand string) interface{} {
|
func write(cmd *cobra.Command, filename string, updatedData interface{}) error {
|
||||||
|
if writeInplace {
|
||||||
|
dataStr, err := yamlToString(updatedData)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return ioutil.WriteFile(filename, []byte(dataStr), 0644)
|
||||||
|
}
|
||||||
|
dataStr, err := toString(updatedData)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
cmd.Println(dataStr)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func mergeProperties(cmd *cobra.Command, args []string) error {
|
||||||
|
if len(args) < 2 {
|
||||||
|
return errors.New("Must provide at least 2 yaml files")
|
||||||
|
}
|
||||||
|
|
||||||
|
updatedData, err := mergeYaml(args)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return write(cmd, args[0], updatedData)
|
||||||
|
}
|
||||||
|
|
||||||
|
func mergeYaml(args []string) (interface{}, error) {
|
||||||
|
var updatedData map[interface{}]interface{}
|
||||||
|
|
||||||
|
for _, f := range args {
|
||||||
|
var parsedData map[interface{}]interface{}
|
||||||
|
if err := readData(f, &parsedData); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if err := merge(&updatedData, parsedData, overwriteFlag); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return mapToMapSlice(updatedData), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func updateParsedData(parsedData yaml.MapSlice, writeCommands yaml.MapSlice, prependCommand string) (interface{}, error) {
|
||||||
var prefix = ""
|
var prefix = ""
|
||||||
if prependCommand != "" {
|
if prependCommand != "" {
|
||||||
prefix = prependCommand + "."
|
prefix = prependCommand + "."
|
||||||
@@ -200,26 +358,29 @@ func updateParsedData(parsedData yaml.MapSlice, writeCommands yaml.MapSlice, pre
|
|||||||
if prependCommand != "" {
|
if prependCommand != "" {
|
||||||
return readMap(parsedData, prependCommand, make([]string, 0))
|
return readMap(parsedData, prependCommand, make([]string, 0))
|
||||||
}
|
}
|
||||||
return parsedData
|
return parsedData, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateYaml(args []string) interface{} {
|
func updateYaml(args []string) (interface{}, error) {
|
||||||
var writeCommands yaml.MapSlice
|
var writeCommands yaml.MapSlice
|
||||||
var prependCommand = ""
|
var prependCommand = ""
|
||||||
if writeScript != "" {
|
if writeScript != "" {
|
||||||
readDataOrDie(writeScript, &writeCommands, false)
|
if err := readData(writeScript, &writeCommands); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
} else if len(args) < 3 {
|
} else if len(args) < 3 {
|
||||||
die("Must provide <filename> <path_to_update> <value>")
|
return nil, errors.New("Must provide <filename> <path_to_update> <value>")
|
||||||
} else {
|
} else {
|
||||||
writeCommands = make(yaml.MapSlice, 1)
|
writeCommands = make(yaml.MapSlice, 1)
|
||||||
writeCommands[0] = yaml.MapItem{Key: args[1], Value: parseValue(args[2])}
|
writeCommands[0] = yaml.MapItem{Key: args[1], Value: parseValue(args[2])}
|
||||||
}
|
}
|
||||||
|
|
||||||
var parsedData yaml.MapSlice
|
var parsedData yaml.MapSlice
|
||||||
err := readData(args[0], &parsedData, inputJSON)
|
if err := readData(args[0], &parsedData); err != nil {
|
||||||
if err != nil {
|
|
||||||
var generalData interface{}
|
var generalData interface{}
|
||||||
readDataOrDie(args[0], &generalData, inputJSON)
|
if err = readData(args[0], &generalData); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
item := yaml.MapItem{Key: "thing", Value: generalData}
|
item := yaml.MapItem{Key: "thing", Value: generalData}
|
||||||
parsedData = yaml.MapSlice{item}
|
parsedData = yaml.MapSlice{item}
|
||||||
prependCommand = "thing"
|
prependCommand = "thing"
|
||||||
@@ -240,74 +401,51 @@ func parseValue(argument string) interface{} {
|
|||||||
if err == nil {
|
if err == nil {
|
||||||
return value
|
return value
|
||||||
}
|
}
|
||||||
|
if argument == "[]" {
|
||||||
|
return make([]interface{}, 0)
|
||||||
|
}
|
||||||
return argument
|
return argument
|
||||||
}
|
}
|
||||||
return argument[1 : len(argument)-1]
|
return argument[1 : len(argument)-1]
|
||||||
}
|
}
|
||||||
|
|
||||||
func print(context interface{}) {
|
func toString(context interface{}) (string, error) {
|
||||||
var out string
|
|
||||||
if outputToJSON {
|
if outputToJSON {
|
||||||
out = jsonToString(context)
|
return jsonToString(context)
|
||||||
} else {
|
|
||||||
out = yamlToString(context)
|
|
||||||
}
|
}
|
||||||
fmt.Println(out)
|
return yamlToString(context)
|
||||||
}
|
}
|
||||||
|
|
||||||
func yamlToString(context interface{}) string {
|
func yamlToString(context interface{}) (string, error) {
|
||||||
out, err := yaml.Marshal(context)
|
out, err := yaml.Marshal(context)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
die("error printing yaml: %v", err)
|
return "", fmt.Errorf("error printing yaml: %v", err)
|
||||||
}
|
}
|
||||||
outStr := string(out)
|
outStr := string(out)
|
||||||
// trim the trailing new line as it's easier for a script to add
|
// trim the trailing new line as it's easier for a script to add
|
||||||
// it in if required than to remove it
|
// it in if required than to remove it
|
||||||
if trimOutput {
|
if trimOutput {
|
||||||
return strings.Trim(outStr, "\n ")
|
return strings.Trim(outStr, "\n "), nil
|
||||||
}
|
}
|
||||||
return outStr
|
return outStr, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func readDataOrDie(filename string, parsedData interface{}, readAsJSON bool) {
|
func readData(filename string, parsedData interface{}) error {
|
||||||
err := readData(filename, parsedData, readAsJSON)
|
|
||||||
if err != nil {
|
|
||||||
die("error parsing data: ", err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func readData(filename string, parsedData interface{}, readAsJSON bool) error {
|
|
||||||
if filename == "" {
|
if filename == "" {
|
||||||
die("Must provide filename")
|
return errors.New("Must provide filename")
|
||||||
}
|
}
|
||||||
|
|
||||||
var rawData []byte
|
var rawData []byte
|
||||||
|
var err error
|
||||||
if filename == "-" {
|
if filename == "-" {
|
||||||
rawData = readStdin()
|
rawData, err = ioutil.ReadAll(os.Stdin)
|
||||||
} else {
|
} else {
|
||||||
rawData = readFile(filename)
|
rawData, err = ioutil.ReadFile(filename)
|
||||||
}
|
}
|
||||||
|
|
||||||
return yaml.Unmarshal([]byte(rawData), parsedData)
|
|
||||||
}
|
|
||||||
|
|
||||||
func readStdin() []byte {
|
|
||||||
bytes, err := ioutil.ReadAll(os.Stdin)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
die("error reading stdin", err)
|
return err
|
||||||
}
|
}
|
||||||
return bytes
|
|
||||||
}
|
|
||||||
|
|
||||||
func readFile(filename string) []byte {
|
return yaml.Unmarshal(rawData, parsedData)
|
||||||
var rawData, readError = ioutil.ReadFile(filename)
|
|
||||||
if readError != nil {
|
|
||||||
die("error: %v", readError)
|
|
||||||
}
|
|
||||||
return rawData
|
|
||||||
}
|
|
||||||
|
|
||||||
func die(message ...interface{}) {
|
|
||||||
fmt.Println(message)
|
|
||||||
os.Exit(1)
|
|
||||||
}
|
}
|
||||||
|
|||||||
48
yaml_test.go
48
yaml_test.go
@@ -24,23 +24,23 @@ func TestParseValue(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestRead(t *testing.T) {
|
func TestRead(t *testing.T) {
|
||||||
result := read([]string{"sample.yaml", "b.c"})
|
result, _ := read([]string{"examples/sample.yaml", "b.c"})
|
||||||
assertResult(t, 2, result)
|
assertResult(t, 2, result)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestReadArray(t *testing.T) {
|
func TestReadArray(t *testing.T) {
|
||||||
result := read([]string{"sample_array.yaml", "[1]"})
|
result, _ := read([]string{"examples/sample_array.yaml", "[1]"})
|
||||||
assertResult(t, 2, result)
|
assertResult(t, 2, result)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestReadString(t *testing.T) {
|
func TestReadString(t *testing.T) {
|
||||||
result := read([]string{"sample_text.yaml"})
|
result, _ := read([]string{"examples/sample_text.yaml"})
|
||||||
assertResult(t, "hi", result)
|
assertResult(t, "hi", result)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestOrder(t *testing.T) {
|
func TestOrder(t *testing.T) {
|
||||||
result := read([]string{"order.yaml"})
|
result, _ := read([]string{"examples/order.yaml"})
|
||||||
formattedResult := yamlToString(result)
|
formattedResult, _ := yamlToString(result)
|
||||||
assertResult(t,
|
assertResult(t,
|
||||||
`version: 3
|
`version: 3
|
||||||
application: MyApp`,
|
application: MyApp`,
|
||||||
@@ -48,7 +48,7 @@ application: MyApp`,
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestNewYaml(t *testing.T) {
|
func TestNewYaml(t *testing.T) {
|
||||||
result := newYaml([]string{"b.c", "3"})
|
result, _ := newYaml([]string{"b.c", "3"})
|
||||||
formattedResult := fmt.Sprintf("%v", result)
|
formattedResult := fmt.Sprintf("%v", result)
|
||||||
assertResult(t,
|
assertResult(t,
|
||||||
"[{b [{c 3}]}]",
|
"[{b [{c 3}]}]",
|
||||||
@@ -56,7 +56,7 @@ func TestNewYaml(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestNewYamlArray(t *testing.T) {
|
func TestNewYamlArray(t *testing.T) {
|
||||||
result := newYaml([]string{"[0].cat", "meow"})
|
result, _ := newYaml([]string{"[0].cat", "meow"})
|
||||||
formattedResult := fmt.Sprintf("%v", result)
|
formattedResult := fmt.Sprintf("%v", result)
|
||||||
assertResult(t,
|
assertResult(t,
|
||||||
"[[{cat meow}]]",
|
"[[{cat meow}]]",
|
||||||
@@ -64,7 +64,7 @@ func TestNewYamlArray(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestUpdateYaml(t *testing.T) {
|
func TestUpdateYaml(t *testing.T) {
|
||||||
result := updateYaml([]string{"sample.yaml", "b.c", "3"})
|
result, _ := updateYaml([]string{"examples/sample.yaml", "b.c", "3"})
|
||||||
formattedResult := fmt.Sprintf("%v", result)
|
formattedResult := fmt.Sprintf("%v", result)
|
||||||
assertResult(t,
|
assertResult(t,
|
||||||
"[{a Easy! as one two three} {b [{c 3} {d [3 4]} {e [[{name fred} {value 3}] [{name sam} {value 4}]]}]}]",
|
"[{a Easy! as one two three} {b [{c 3} {d [3 4]} {e [[{name fred} {value 3}] [{name sam} {value 4}]]}]}]",
|
||||||
@@ -72,7 +72,7 @@ func TestUpdateYaml(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestUpdateYamlArray(t *testing.T) {
|
func TestUpdateYamlArray(t *testing.T) {
|
||||||
result := updateYaml([]string{"sample_array.yaml", "[0]", "3"})
|
result, _ := updateYaml([]string{"examples/sample_array.yaml", "[0]", "3"})
|
||||||
formattedResult := fmt.Sprintf("%v", result)
|
formattedResult := fmt.Sprintf("%v", result)
|
||||||
assertResult(t,
|
assertResult(t,
|
||||||
"[3 2 3]",
|
"[3 2 3]",
|
||||||
@@ -80,17 +80,37 @@ func TestUpdateYamlArray(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestUpdateYaml_WithScript(t *testing.T) {
|
func TestUpdateYaml_WithScript(t *testing.T) {
|
||||||
writeScript = "instruction_sample.yaml"
|
writeScript = "examples/instruction_sample.yaml"
|
||||||
updateYaml([]string{"sample.yaml"})
|
_, _ = updateYaml([]string{"examples/sample.yaml"})
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestUpdateYaml_WithUnknownScript(t *testing.T) {
|
||||||
|
writeScript = "fake-unknown"
|
||||||
|
_, err := updateYaml([]string{"examples/sample.yaml"})
|
||||||
|
if err == nil {
|
||||||
|
t.Error("Expected error due to unknown file")
|
||||||
|
}
|
||||||
|
expectedOutput := `open fake-unknown: no such file or directory`
|
||||||
|
assertResult(t, expectedOutput, err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestNewYaml_WithScript(t *testing.T) {
|
func TestNewYaml_WithScript(t *testing.T) {
|
||||||
writeScript = "instruction_sample.yaml"
|
writeScript = "examples/instruction_sample.yaml"
|
||||||
expectedResult := `b:
|
expectedResult := `b:
|
||||||
c: cat
|
c: cat
|
||||||
e:
|
e:
|
||||||
- name: Mike Farah`
|
- name: Mike Farah`
|
||||||
result := newYaml([]string{""})
|
result, _ := newYaml([]string{""})
|
||||||
actualResult := yamlToString(result)
|
actualResult, _ := yamlToString(result)
|
||||||
assertResult(t, expectedResult, actualResult)
|
assertResult(t, expectedResult, actualResult)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestNewYaml_WithUnknownScript(t *testing.T) {
|
||||||
|
writeScript = "fake-unknown"
|
||||||
|
_, err := newYaml([]string{""})
|
||||||
|
if err == nil {
|
||||||
|
t.Error("Expected error due to unknown file")
|
||||||
|
}
|
||||||
|
expectedOutput := `open fake-unknown: no such file or directory`
|
||||||
|
assertResult(t, expectedOutput, err.Error())
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user