Ymlio is a cli tool that splits and combines yaml files and deals with multiple special cases (See below):
see https://go.dev/doc/install
go install github.com/mekkyz/ymlio@latest
The ymlio tool is a binary file and needs no installation. The only prerequisite is that you have access as an administrator on the OS you are installing it on. Download the latest release for your OS from here
On Linux, make this file executable by doing: chmod u+x ymlio.
On Windows, the file should be executable by default, i.e. do nothing.
On macOS, make this file executable by doing: chmod u+x ymlio.amd.osx or chmod u+x ymlio.arm.osx. If the there is a security pop-up when running the command, please also Allow the executable in System Preferences > Security & Privacy.
If you want to use the tool globally just copy the ymlio file to your bin folder using sudo cp ymlio /usr/local/bin/ymlio
This is also capable of extracting only some files using the --only flag. It handles also other types of files (currently handles in addition to yaml also normal text files if they have the string __RAW and it can import content of other files if they have the string __IMPORT)
-
ymlio split file.ymlThis should split all the files in the yaml file. -
ymlio split file.yml --only key1.yml key2.ymlthis should only split the specified files after the--onlytag.- Special case: if there is only one file specified after
--only-> it will export this file and also print it out to the terminal. -> Stdout Example:ymlio split file.yml --only key.yml
- Special case: if there is only one file specified after
-
The tool also handles
__RAWTags while splitting.- If there is a file in the file.yml with the tag
__RAWThe program will handle it as plain text. This is also handled incombine
- If there is a file in the file.yml with the tag
-
If the file name is
-it will its content from Stdin Example:ymlio split -orymlio split - --only key.yml -
The tool also handles
__IMPORTTags while splitting.- If there is a file in the file.yml with the tag
__IMPORTThe program will import the content of the specified file under__IMPORT. Example:
importtest __IMPORT: m1.md
This will import the content of m1.md file. The m1.md must be in the same folder as the file.yml
- If there is a file in the file.yml with the tag
-
The tool also handles
anchors- To know more about yaml anchors simply follow this link: https://support.atlassian.com/bitbucket-cloud/docs/yaml-anchors/
This can also handle other types of files mentioned under 1. Splitting
-
ymlio combine file1.yml file2.yml combined.ymlThis should combine all the files before the last argument and put them together in the last argument. The command here will combinefile1.ymlandfile2.ymland adds them tocombined.yml(If the filecombined.ymlnot there, it will be created)- If the
combined.ymlis already there. It will be overwritten - If you want to append to it using the flag
--extendExample:ymlio combine file1.yml file2.yml combined.yml --extend
- If the
-
The combine also handles
__RAW- If the program detects a file with a text content (not a yaml format). It will put the tag
__RAWto it.
- If the program detects a file with a text content (not a yaml format). It will put the tag