def doc_of
import cswap-bend-cli@0.1.0.0/fmt/out.bend as Outimport Base
import cswap-bend-cli@0.1.0.0/json.bend as Json
import cswap-bend-cli@0.1.0.0/cmd.bend as Cmd
124# The JSON document a command's output stands for: its own JSON when stdout
125# holds an object or array; else `{schemaVersion, message}` for a success and
126# `{schemaVersion, error:{type, message}}` for an exit-1 error that went to
127# stderr; none for a usage error (exit 2).
128def doc_of(o: Cmd.Out) -> Maybe<&2, Json.Json>:
129 match o:
130 case Cmd.Out{code, +out, err}:
131 doc2(is_doc(Json.parse(out)), Json.parse(out), code, out, err)