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

Compare commits

..

3 Commits
1.3 ... 1.4

Author SHA1 Message Date
Mike Farah
037314af8a Merge pull request #2 from chaos95/master
Handle 'index out of range' errors more gracefully
2016-03-19 13:05:57 +11:00
Morgan Larosa
2a283b4ef7 Fix #1 2016-03-16 16:11:06 +11:00
Mike Farah
7ef556f22b Update README.md 2015-11-20 21:42:45 +11:00
3 changed files with 18 additions and 6 deletions

View File

@@ -3,6 +3,12 @@ yaml is a lightweight and flexible command-line YAML processor
The aim of the project is to be the [jq](https://github.com/stedolan/jq) or sed of yaml files.
## Install
[Download latest binary](https://github.com/mikefarah/yaml/releases/latest) or alternatively:
```
go get github.com/mikefarah/yaml
```
## Features
- Written in portable go, so you can download a lovely dependency free binary
- Deep read a yaml file with a given path
@@ -11,11 +17,6 @@ The aim of the project is to be the [jq](https://github.com/stedolan/jq) or sed
- Convert from json to yaml
- Convert from yaml to json
[Download latest binary](https://github.com/mikefarah/yaml/releases/latest) or alternatively:
```
go get github.com/mikefarah/yaml
```
## Read examples
```
yaml r <yaml file> <path>

View File

@@ -58,7 +58,7 @@ func recurse(value interface{}, head string, tail []string) interface{} {
}
func readArray(array []interface{}, head int64, tail []string) interface{} {
if head > int64(len(array)) {
if head >= int64(len(array)) {
return nil
}

View File

@@ -83,6 +83,17 @@ b:
assertResult(t, nil, readMap(data, "b", []string{"d", "3"}))
}
func TestReadMap_with_array_out_of_bounds_by_1(t *testing.T) {
var data = parseData(`
---
b:
d:
- 3
- 4
`)
assertResult(t, nil, readMap(data, "b", []string{"d", "2"}))
}
func TestReadMap_with_array_splat(t *testing.T) {
var data = parseData(`
e: