mirror of
https://github.com/mikefarah/yq.git
synced 2026-09-01 14:14:52 +08:00
Add --properties-separator option (#1951)
This commit adds the --properties-separator option, which lets users specify the separator used between keys and values in the properties output format. This is done by adjusting the value of github.com/magiconair/properties#Properties.WriteSeparator at encode time. Some refactoring of the properties encoder unit tests was done to make it easier to write unit tests that include different separator values. Fixes: #1864 Signed-off-by: Ryan Drew <ryan.drew@isovalent.com>
This commit is contained in:
@@ -120,6 +120,36 @@ emptyArray =
|
||||
emptyMap =
|
||||
```
|
||||
|
||||
## Encode properties: use custom separator
|
||||
Provide a custom key-value separator using the `--properties-separator` flag.
|
||||
|
||||
Given a sample.yml file of:
|
||||
```yaml
|
||||
# block comments come through
|
||||
person: # neither do comments on maps
|
||||
name: Mike Wazowski # comments on values appear
|
||||
pets:
|
||||
- cat # comments on array values appear
|
||||
food: [pizza] # comments on arrays do not
|
||||
emptyArray: []
|
||||
emptyMap: []
|
||||
|
||||
```
|
||||
then
|
||||
```bash
|
||||
yq -o props --properties-separator=";" sample.yml
|
||||
```
|
||||
will output
|
||||
```properties
|
||||
# block comments come through
|
||||
# comments on values appear
|
||||
person.name;Mike Wazowski
|
||||
|
||||
# comments on array values appear
|
||||
person.pets.0;cat
|
||||
person.food.0;pizza
|
||||
```
|
||||
|
||||
## Decode properties
|
||||
Given a sample.properties file of:
|
||||
```properties
|
||||
|
||||
Reference in New Issue
Block a user