A program of mine has a large configuration file in YAML syntax. I am thinking about splitting the large file into multiple files to make them easier to edit (ideally files will be small, fitting one page). The loader procedure will traverse the file hierarchy, use file names as YAML associative array keys, and insert file contents as the corresponding values. Only associative arrays at the top of YAML hierarchy will be split this way, any other syntax will have to be contained within leaf files.
A simple file hierarchy example demonstrated using GNU find
and tail
:
$ find . -type f
./foo
./bar
./baz/color
./baz/shape
$ tail `find . -type f`
==> ./foo <==
color: red
shape: circle
==> ./bar <==
color: [black, white]
shape: "deep channel"
==> ./baz/color <==
magenta
==> ./baz/shape <==
star
The YAML equivalent would be:
foo:
color: red
shape: circle
bar:
color: [black, white]
shape: "deep channel"
baz:
color: magenta
shape: star
The idea seems simple and practical but surprisingly I cannot find any implementations. I am about to wrap my own but if you have seen something similar I would like to take a look before I have built another bicycle 🙂