fmerge

Crates.iofmerge
lib.rsfmerge
version0.1.6
sourcesrc
created_at2023-04-04 23:11:24.81075
updated_at2023-08-05 06:29:43.344625
descriptionMerging files recursively.
homepagehttps://replicadse.github.io/fmerge
repositoryhttps://github.com/replicadse/fmerge
max_upload_size
id830539
size69,145
Alexander Weber (replicadse)

documentation

README

fmerge

fmerge is a tool that allows merging files recursively and with custom placeholder patterns. The include file statements are always relative to the file that includes them.

Example

Test data

root.json

{
    "data": [
        {{ ./item1.json }},
        {{ ./item2.json }}
    ]
}

item1.json

{
    "name": "Item 1",
    "data": {{ ./item_data.json }}
}

item2.json

{
    "name": "Item 2",
    "data": {{ ./item_data.json }}
}

item_data.json

{
    "foo": "bar"
}

Execution

Merging these files together can be done by executing the following code:

fmerge merge -f=./root.json -p="{{ %f }}"

The resulting file will be printed to STDOUT and will look like this:

{
    "data": [
        {
    "name": "Item 1",
    "data": {
    "foo": "bar"
}
},
        {
    "name": "Item 2",
    "data": {
    "foo": "bar"
}
}
    ]
}

The text replacement is done without respect to the formatting. The structure above is valid JSON, just formatted incorrectly. fmerge does not modify the content it merges in any way, shape or form.
The correctly formatting JSON looks as follows:

{
  "data": [
    {
      "name": "Item 1",
      "data": {
        "foo": "bar"
      }
    },
    {
      "name": "Item 2",
      "data": {
        "foo": "bar"
      }
    }
  ]
}

Commit count: 12

cargo fmt