main.tri (1128B)
1 !import foundation as B 2 !import fileio as IO 3 !import inspection as Inspect 4 !export main 5 6 -- These three modules are generated offline package bindings, not library source. 7 -- main accepts a path through `arboricx run --arg PATH --io --allow-read PATH`. 8 -- Select --no-result so the final IO value adds no bytes to the report. 9 -- Read once: the digest and report always describe the same byte snapshot. 10 main path = (IO.io (IO.bind (IO.readFile path) 11 (reply : B.matchResult 12 (message _ : IO.abortIO (B.append "Read failed: " message)) 13 (bytes _ : B.matchResult 14 (code _ : IO.abortIO (B.append "Invalid Arboricx bundle: " (B.append (Inspect.describeError code) 15 (B.append " (code " (B.append (B.showNumber code) ")"))))) 16 (summary _ : IO.bind (IO.sha256Hex bytes) 17 (digestReply : B.matchResult 18 (message _ : IO.abortIO (B.append "Hash failed: " message)) 19 (digest _ : IO.putStr (B.append "arboricx.inspect.v1\nbundle-sha256\t" 20 (B.append digest (B.append "\n" (Inspect.renderSummary summary))))) 21 digestReply)) 22 (Inspect.inspectBundle bytes)) 23 reply)))