{"id":13903063,"url":"https://github.com/matthewadams/ymlx","last_synced_at":"2025-04-11T22:04:31.667Z","repository":{"id":57403946,"uuid":"125729368","full_name":"matthewadams/ymlx","owner":"matthewadams","description":"Command-line YAML processor","archived":false,"fork":false,"pushed_at":"2019-02-06T15:03:43.000Z","size":146,"stargazers_count":81,"open_issues_count":0,"forks_count":5,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-11T22:02:43.707Z","etag":null,"topics":["cli","command-line-tool","yaml","yaml-parser","yml"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/matthewadams.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-03-18T13:46:21.000Z","updated_at":"2024-11-14T19:06:41.000Z","dependencies_parsed_at":"2022-09-15T20:01:49.414Z","dependency_job_id":null,"html_url":"https://github.com/matthewadams/ymlx","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matthewadams%2Fymlx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matthewadams%2Fymlx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matthewadams%2Fymlx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matthewadams%2Fymlx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/matthewadams","download_url":"https://codeload.github.com/matthewadams/ymlx/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248487717,"owners_count":21112191,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","command-line-tool","yaml","yaml-parser","yml"],"created_at":"2024-08-06T22:01:35.715Z","updated_at":"2025-04-11T22:04:31.639Z","avatar_url":"https://github.com/matthewadams.png","language":"JavaScript","funding_links":[],"categories":["JavaScript","cli"],"sub_categories":[],"readme":"Command-line YAML processing tool\n\n## Features\n\n* Plain JavaScript to manipulate document(s)\n\n## Install\n\n```\n$ npm install -g ymlx\n```\n\n## Usage\n\nPipe into `ymlx` any YAML and anonymous function for reducing it.\n\n```\n$ cat my.yaml | ymlx [code ...]\n```\n\n### Anonymous function\n\nUse an anonymous function as reducer which gets YAML as an object and processes it:\n```\n$ echo 'foo: [bar: value]' | ymlx 'x =\u003e x.foo[0].bar'\nvalue\n```\n\n### `this` Binding\n\nIf you don't pass anonymous function `param =\u003e ...`, code will be automatically transformed into anonymous function.\nAnd you can get access to YAML by `this` keyword:\n```\n$ echo 'foo: [bar: value]' | ymlx 'this.foo[0].bar'\nvalue\n```\n\n#### Multiple Documents\n\nYou can pass a YAML file with multiple documents (using the `---` separator), and your commands will be applied to each document.\n\n```yaml\n# test.yml\n---\nfoo:\n- bar: value\n---\nfoo:\n- bar: another\n```\n\n```\n$ cat test.yml | ymlx 'this.foo[0].bar'\n---\nvalue\n---\nanother\n```\n\n### Chain\n\nYou can pass any number of anonymous functions for reducing JSON:\n```\n$ echo 'foo: [bar: value]' | ymlx 'x =\u003e x.foo' 'this[0]' 'this.bar'\nvalue\n```\n\n### Generator\n\nIf passed code contains `yield` keyword, [generator expression](https://github.com/sebmarkbage/ecmascript-generator-expression)\nwill be used:\n```\n$ curl ... | ymlx 'for (let user of this) if (user.login.startsWith(\"a\")) yield user'\n```\n\nAccess to YAML through `this` keyword:\n```yaml\n# test.yml\n- a\n- b\n```\n\n```\n$ cat test.yml | ymlx 'yield* this'\n- a\n- b\n```\n\n```\n$ cat test.yml | ymlx 'yield* this; yield \"c\";'\n- a\n- b\n- c\n```\n\n### Update\n\nYou can update existing YAML using spread operator:\n\n```\n$ echo 'count: 0' | ymlx '{...this, count: 1}'\ncount: 1\n```\n\n### Use npm package\n\nUse any npm package by installing globally or in the current working directory:\n```\n$ npm install lodash # -g if you want\n$ cat 'count: 0' | ymlx 'require(\"lodash\").keys(this)'\n- count\n```\n\n### Formatting\n```\n$ echo '[1,2,3]' | ymlx 'this.reduce((a,n) =\u003e a += n.toString(), \"concat: \")'\n'concat: 123'\n```\n\n## Inspiration\n\n`ymlx` was inspired by [`fx`](https://github.com/antonmedv/fx)\n\n## Related\n\n* [jq](https://github.com/stedolan/jq) – cli JSON processor on C\n* [jsawk](https://github.com/micha/jsawk) – like awk, but for JSON\n* [json](https://github.com/trentm/json) – another JSON manipulating cli library\n* [jl](https://github.com/chrisdone/jl) – functional sed for JSON on Haskell\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatthewadams%2Fymlx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmatthewadams%2Fymlx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatthewadams%2Fymlx/lists"}