Check the Templates

Either every Template keeps its rules, or the check says which does not.

check reads every Template in the project and prints one line for each. A Template is valid when its types and its tree keep every rule, and broken otherwise, with the problem.

$ vendor/bin/barntree check
Barn: …/allotment
Checking the trees in …/allotment/.barn/barntree/trees
Allotment: valid

Make a Template that refers to a type it doesn’t have, and check again:

$ vendor/bin/barntree check
Barn: …/allotment
Checking the trees in …/allotment/.barn/barntree/trees
Allotment: valid
Pond: broken: Type 'Pond' is of 'Fish', which is not one of the tree's types.

A file that doesn’t name a Template, or names one another file already holds, stops the check before any Template is read. Barntree won’t leave a Template out of the list without saying so:

$ vendor/bin/barntree check
Barn: …/allotment
Checking the trees in …/allotment/.barn/barntree/trees
fault: …/allotment/.barn/barntree/trees/Notes.barntree.json: it doesn't name a tree.

The exit status is 1 if any Template is broken or any file is a fault, and 0 otherwise, which makes it a step in a build:

- run: vendor/bin/barntree check

Where it looks #

check finds the barn from any folder inside it, and says which it is using. It reads .barn/barntree/trees/, every .barntree.json file in it, however deep. Outside any barn it refuses, writes nothing and exits with 1.

$ mkdir -p sub/deeper
$ cd sub/deeper
$ ../../vendor/bin/barntree check
Barn: …/allotment
Checking the trees in …/allotment/.barn/barntree/trees
Allotment: valid

It checks Templates. A Construction is validated whenever it is read.