Decoder Properties (#1099)

* Decoder Properties

* Added properties round trip test

* Fixed property decode for github actions

* Refactored XML test to use common functions

* Switched formatScenario parameter order for more readablity
This commit is contained in:
Mike Farah
2022-02-10 12:02:53 +11:00
committed by GitHub
parent 4d4bd5114d
commit a9c3617b4f
14 changed files with 464 additions and 191 deletions
+66 -3
View File
@@ -27,7 +27,7 @@ emptyMap: []
```
then
```bash
yq -o=props -I=0 '.' sample.yml
yq -o=props sample.yml
```
will output
```properties
@@ -54,7 +54,7 @@ emptyMap: []
```
then
```bash
yq -o=props -I=0 '... comments = ""' sample.yml
yq -o=props '... comments = ""' sample.yml
```
will output
```properties
@@ -80,7 +80,7 @@ emptyMap: []
```
then
```bash
yq -o=props -I=0 '(.. | select( (tag == "!!map" or tag =="!!seq") and length == 0)) = ""' sample.yml
yq -o=props '(.. | select( (tag == "!!map" or tag =="!!seq") and length == 0)) = ""' sample.yml
```
will output
```properties
@@ -94,3 +94,66 @@ emptyArray =
emptyMap =
```
## Decode properties
Given a sample.properties file of:
```properties
# comments on values appear
person.name = Mike
# comments on array values appear
person.pets.0 = cat
person.food.0 = pizza
```
then
```bash
yq -p=props sample.properties
```
will output
```yaml
person:
name: Mike # comments on values appear
pets:
- cat # comments on array values appear
food:
- pizza
```
## Roundtrip
Given a sample.properties file of:
```properties
# comments on values appear
person.name = Mike
# comments on array values appear
person.pets.0 = cat
person.food.0 = pizza
```
then
```bash
yq -p=props -o=props '.person.pets.0 = "dog"' sample.properties
```
will output
```properties
# comments on values appear
person.name = Mike
# comments on array values appear
person.pets.0 = dog
person.food.0 = pizza
```
## Empty doc
Given a sample.properties file of:
```properties
```
then
```bash
yq -p=props sample.properties
```
will output
```yaml
```