{"id":13586692,"url":"https://github.com/thecodingmachine/yaml-tools","last_synced_at":"2025-07-24T15:06:08.114Z","repository":{"id":50207527,"uuid":"133039835","full_name":"thecodingmachine/yaml-tools","owner":"thecodingmachine","description":"A set of CLI tools to manipulate YAML files (merge, edit, etc...)","archived":false,"fork":false,"pushed_at":"2022-12-08T02:05:32.000Z","size":62,"stargazers_count":20,"open_issues_count":4,"forks_count":2,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-04-11T18:59:53.377Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thecodingmachine.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-05-11T12:57:09.000Z","updated_at":"2025-01-24T15:27:33.000Z","dependencies_parsed_at":"2023-01-24T05:01:05.025Z","dependency_job_id":null,"html_url":"https://github.com/thecodingmachine/yaml-tools","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thecodingmachine%2Fyaml-tools","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thecodingmachine%2Fyaml-tools/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thecodingmachine%2Fyaml-tools/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thecodingmachine%2Fyaml-tools/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thecodingmachine","download_url":"https://codeload.github.com/thecodingmachine/yaml-tools/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249097876,"owners_count":21212366,"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":[],"created_at":"2024-08-01T15:05:44.865Z","updated_at":"2025-04-15T15:31:08.108Z","avatar_url":"https://github.com/thecodingmachine.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/thecodingmachine/yaml-tools.svg?branch=master)](https://travis-ci.org/thecodingmachine/yaml-tools)\n[![Coverage Status](https://coveralls.io/repos/github/thecodingmachine/yaml-tools/badge.svg?branch=master)](https://coveralls.io/github/thecodingmachine/yaml-tools?branch=master)\n\n# Yaml-tools\n\nA set of CLI tools to manipulate YAML files (merge, delete, etc...) with comment preservation, based on [ruamel.yaml](http://yaml.readthedocs.io/en/latest/) \n\n## Getting Started\n\n### Prerequisites\n- Python3 (with pip)\n\n### Installation\n*(For development see section at the end)*\n```\n$ pip install ruamel.yaml\n$ export YAML_TOOLS_VERSION=0.0.6\n$ sudo wget https://raw.githubusercontent.com/thecodingmachine/yaml-tools/${YAML_TOOLS_VERSION}/src/yaml_tools.py -O /usr/local/bin/yaml-tools\n$ sudo chmod +x /usr/local/bin/yaml-tools\n```\n\n## Usage\n```\n$ yaml-tools \u003ccommand\u003e [\u003cargs\u003e] \n```\n\nThere are 4 commands at the moment :\n\n### 1) merge\nMerges two or more yaml files and preserves the comments.\n```\n$ yaml-tools merge -i INPUTS [INPUTS ...] [-o OUTPUT]\n```\n- **INPUTS**: paths to input yaml files, which will be merged from the last to the first.\n- **OUTPUT**: path to output yaml file (or sys.stdout by default).\n\n### 2) delete\nDeletes one item/block (**and its preceding comments**) from the input yaml file.\n```\n$ yaml-tools delete PATH_TO_KEY -i INPUT [-o OUTPUT]\n```\n- **PATH_TO_KEY**: \"path\" to access the yaml item/block which will be deleted, e.g. `key1 0 key2`\n- **INPUT**: path to input yaml file.\n- **OUTPUT**: path to output yaml file (or sys.stdout by default).\n\n### 3) normalize-docker-compose\nNormalize the input docker-compose file by and converting all key-value string (e.g. 'foo=bar' or '80:8080') \nto key-value dicts inside the services' `labels` and `environment` fields,\nalso delete all duplicated volumes and env_file (**and its preceding comments**) for each services\n```\n$ yaml-tools normalize-docker-compose -i INPUT [-o OUTPUT]\n```\n- **INPUT**: path to input yaml file.\n- **OUTPUT**: path to output yaml file (or sys.stdout by default).\n\n### 4) comment (/!\\ EXPERIMENTAL)\nComments one item/block from the input yaml file and preserves the comments.\n\n/!\\ There are somme issues with comments which are at the end of any intermediate level/block, \nand also commenting the last item from a list, so use it with caution.\n```\n$ yaml-tools comment PATH_TO_KEY -i INPUT [-o OUTPUT]\n```\n- **PATH_TO_KEY**: \"path\" to access the yaml item which will be commented, e.g. `key1 0 key2`\n- **INPUT**: path to input yaml file.\n- **OUTPUT**: path to output yaml file (or sys.stdout by default).\n\n## Dev\n\n### Installing\n- Open a terminal console on this project's root folder\n- Create a virtual environment with `python -m venv venv` (or `python3 -m venv venv`)\n- Activate your venv with `.\\venv\\Scripts\\activate` (Windows) or `source ./venv/bin/activate` (Linux or MacOS)\n- Install all required packages with `pip install -r requirements.txt`\n\n## Running tests\n```\n$ cd src/tests/\n\n$ python -m unittest discover \nor\n$ coverage run --rcfile=../../.coveragerc --source=.,.. -m unittest discover \u0026\u0026 coverage report -m\n```\n##\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthecodingmachine%2Fyaml-tools","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthecodingmachine%2Fyaml-tools","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthecodingmachine%2Fyaml-tools/lists"}