Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/shubham1172/ym
YAML manipulator CLI
https://github.com/shubham1172/ym
Last synced: about 1 month ago
JSON representation
YAML manipulator CLI
- Host: GitHub
- URL: https://github.com/shubham1172/ym
- Owner: shubham1172
- License: apache-2.0
- Created: 2023-02-02T09:44:21.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-02-08T17:52:00.000Z (almost 2 years ago)
- Last Synced: 2024-10-20T23:46:20.096Z (2 months ago)
- Language: Go
- Size: 18.6 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ym
YAML manipulator CLI`ym` is a CLI tool to manipulate YAML files. It allows you to define a set of operations to apply to a YAML file and execute them.
## Install
```bash
go install github.com/shubham1172/ym@latest
```## Example
If you have a `foo.yaml` file with the following content:
```yaml
people:
- name: John
age: 42
- name: Jane
age: 36
- name: Judy
age: 34
```Create a file `ops.yaml` with the following content:
```yaml
- input: foo.yaml # The file to apply the operations to, relative to the current directory.
output: generated-foo.yaml # If this is not set, the file will be updated in place.
operations:
- op: update
path: .people[0].age # Follows a yq style path.
value: 43
- op: update
path: .people[1].children
value:
- name: Jack
age: 10
- name: Jill
age: 8
- op: delete
path: .people[2]
```Then run `ym`:
```bash
# Run ym with the ops.yaml file.
ym -file ops.yaml
# Or, pipe the ops.yaml file to ym.
cat ops.yaml | ym
```The `foo.yaml` file will be updated to:
```yaml
people:
- name: John
age: 43
- name: Jane
age: 36
children:
- name: Jack
age: 10
- name: Jill
age: 8
```## Credits
This project uses https://github.com/mikefarah/yq for YAML manipulation.