yq/pkg/yqlib/doc/Style Operator.md
2020-11-18 09:50:52 +11:00

80 lines
804 B
Markdown

## Examples
### Example 0
Given a sample.yml file of:
```yaml
a: cat
```
then
```bash
yq eval '.a style="single"' sample.yml
```
will output
```yaml
{a: 'cat'}
```
### Set style using a path
Given a sample.yml file of:
```yaml
a: cat
b: double
```
then
```bash
yq eval '.a style=.b' sample.yml
```
will output
```yaml
{a: "cat", b: double}
```
### Example 2
Given a sample.yml file of:
```yaml
a: cat
b: dog
```
then
```bash
yq eval '.. style=""' sample.yml
```
will output
```yaml
a: cat
b: dog
```
### Example 3
Given a sample.yml file of:
```yaml
a: cat
b: thing
```
then
```bash
yq eval '.. | style' sample.yml
```
will output
```yaml
flow
double
single
```
### Example 4
Given a sample.yml file of:
```yaml
a: cat
```
then
```bash
yq eval '.. | style' sample.yml
```
will output
```yaml
```