54 lines
1.8 KiB
Plaintext
54 lines
1.8 KiB
Plaintext
!import "arboricx-manifest.tri" !Local
|
|
|
|
-- Read and validate a full Arboricx bundle.
|
|
-- Returns (pair validManifest afterContainer).
|
|
-- The manifest core fields are validated against expected values.
|
|
readArboricxBundle = (bs :
|
|
bindResult (readArboricxRequiredSections bs)
|
|
(sections afterContainer :
|
|
matchPair
|
|
(manifestBytes _ :
|
|
bindResult (readManifest manifestBytes)
|
|
(parsedManifest afterManifest :
|
|
matchPair
|
|
(coreManifest metadataWithExtensions :
|
|
bindResult (validateManifestCore coreManifest afterManifest)
|
|
(validCore _ : ok (pair validCore metadataWithExtensions) afterContainer))
|
|
parsedManifest))
|
|
sections))
|
|
|
|
-- Select an export from a validated bundle and reconstruct its root tree.
|
|
-- Returns ok executable afterContainer, or propagates parse/selection/node errors.
|
|
readArboricxExecutableByName = (nameBytes bs :
|
|
bindResult (readArboricxBundle bs)
|
|
(bundleResult afterBundle :
|
|
matchPair
|
|
(validCore _ :
|
|
bindResult (selectExport (manifestExports validCore) nameBytes)
|
|
(selectedExport _ :
|
|
readArboricxTreeFromHash (exportRoot selectedExport) bs))
|
|
bundleResult))
|
|
|
|
readArboricxExecutable = (bs :
|
|
readArboricxExecutableByName [] bs)
|
|
|
|
applyArgs = (f args :
|
|
foldl
|
|
(acc arg : acc arg)
|
|
f
|
|
args)
|
|
|
|
runArboricxByName = (nameBytes bs arg :
|
|
bindResult (readArboricxExecutableByName nameBytes bs)
|
|
(executable rest : ok (executable arg) rest))
|
|
|
|
runArboricx = (bs arg :
|
|
runArboricxByName [] bs arg)
|
|
|
|
runArboricxArgsByName = (nameBytes bs args :
|
|
bindResult (readArboricxExecutableByName nameBytes bs)
|
|
(executable rest : ok (applyArgs executable args) rest))
|
|
|
|
runArboricxArgs = (bs args :
|
|
runArboricxArgsByName [] bs args)
|