MCPcopy Create free account
hub / github.com/PerpetualSoftware/pad / EmitJSON

Function EmitJSON

internal/cmdhelp/json.go:73–78  ·  view source on GitHub ↗

EmitJSON walks the command tree below `target`, builds a cmdhelp v0.1 Document, and writes it to w as indented JSON terminated by a newline. `root` MUST be the root cobra command (used to derive global flags and command-path keys relative to the binary). `target` is where the user requested help; p

(target, root *cobra.Command, opts Options, w io.Writer)

Source from the content-addressed store, hash-verified

71// command-path keys relative to the binary). `target` is where the user
72// requested help; pass root for both when the user runs `<cmd> help`.
73func EmitJSON(target, root *cobra.Command, opts Options, w io.Writer) error {
74 doc := Build(target, root, opts)
75 enc := json.NewEncoder(w)
76 enc.SetIndent("", " ")
77 return enc.Encode(doc)
78}
79
80// Build returns a cmdhelp Document without serializing it. Callers that
81// need to inspect or further mutate the document (tests, dynamic enum

Calls 2

BuildFunction · 0.85
EncodeMethod · 0.65