mirror of
https://github.com/mikefarah/yq.git
synced 2026-09-01 14:14:52 +08:00
Adding shebang documentation
This commit is contained in:
@@ -35,6 +35,40 @@ a:
|
||||
c: frog
|
||||
```
|
||||
|
||||
## Flags in expression files
|
||||
You can specify flags on the shebang line, this only works when executing the file directly.
|
||||
|
||||
Given a sample.yaml file of:
|
||||
```yaml
|
||||
a:
|
||||
b: old
|
||||
```
|
||||
And an 'update.yq' expression file of:
|
||||
```bash
|
||||
#! yq -oj
|
||||
|
||||
# This is a yq expression that updates the map
|
||||
# for several great reasons outlined here.
|
||||
|
||||
.a.b = "new" # line comment here
|
||||
| .a.c = "frog"
|
||||
|
||||
# Now good things will happen.
|
||||
```
|
||||
then
|
||||
```bash
|
||||
./update.yq sample.yaml
|
||||
```
|
||||
will output
|
||||
```yaml
|
||||
{
|
||||
"a": {
|
||||
"b": "new",
|
||||
"c": "frog"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Commenting out yq expressions
|
||||
Note that `c` is no longer set to 'frog'. In this example we're calling yq directly and passing the expression file into `--from-file`, this is no different from executing the expression file directly.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user