MCPcopy Index your code
hub / github.com/compozy/agh / writeCommandOutput

Function writeCommandOutput

internal/cli/format.go:129–162  ·  view source on GitHub ↗
(cmd *cobra.Command, bundle outputBundle)

Source from the content-addressed store, hash-verified

127}
128
129func writeCommandOutput(cmd *cobra.Command, bundle outputBundle) error {
130 mode, err := resolveOutputFormat(cmd)
131 if err != nil {
132 return err
133 }
134
135 switch mode {
136 case OutputJSON:
137 return writeJSON(cmd, bundle.jsonValue)
138 case OutputJSONL:
139 if bundle.jsonl == nil {
140 return errors.New("cli: jsonl formatter is required")
141 }
142 return bundle.jsonl(cmd)
143 case OutputToon:
144 if bundle.toon == nil {
145 return errors.New("cli: toon formatter is required")
146 }
147 rendered, err := bundle.toon()
148 if err != nil {
149 return err
150 }
151 return writeRawCommandOutput(cmd, rendered)
152 default:
153 if bundle.human == nil {
154 return errors.New("cli: human formatter is required")
155 }
156 rendered, err := bundle.human()
157 if err != nil {
158 return err
159 }
160 return writeRawCommandOutput(cmd, rendered)
161 }
162}
163
164func writeJSONLine(cmd *cobra.Command, value any) error {
165 encoder := json.NewEncoder(cmd.OutOrStdout())

Callers 15

writeLogsOutputFunction · 0.85
newBundleCatalogCommandFunction · 0.85
newBundlePreviewCommandFunction · 0.85
newBundleActivateCommandFunction · 0.85
newBundleListCommandFunction · 0.85
newBundleGetCommandFunction · 0.85
newBundleUpdateCommandFunction · 0.85
newProviderListCommandFunction · 0.85

Calls 3

resolveOutputFormatFunction · 0.85
writeRawCommandOutputFunction · 0.85
writeJSONFunction · 0.70

Tested by 1