MCPcopy Create free account
hub / github.com/openclaw/gogcli / writeDocsWriteOrphanResult

Function writeDocsWriteOrphanResult

internal/cmd/docs_write_orphans.go:212–250  ·  view source on GitHub ↗
(ctx context.Context, docID, tabID string, orphans []docsWriteOrphanComment)

Source from the content-addressed store, hash-verified

210}
211
212func writeDocsWriteOrphanResult(ctx context.Context, docID, tabID string, orphans []docsWriteOrphanComment) error {
213 if len(orphans) == 0 {
214 return nil
215 }
216 result := docsWriteOrphanResult{
217 DocumentID: docID,
218 TabID: tabID,
219 WouldOrphan: orphans,
220 }
221 if outfmt.IsJSON(ctx) {
222 if err := outfmt.WriteJSON(ctx, stdoutWriter(ctx), result); err != nil {
223 return err
224 }
225 return &ExitError{Code: exitCodeOrphaned, Err: nil}
226 }
227
228 u := ui.FromContext(ctx)
229 u.Err().Linef("docs write blocked: %d open comment(s) would become orphaned", len(orphans))
230 lastAuthor := ""
231 for _, orphan := range orphans {
232 author := strings.TrimSpace(orphan.Author)
233 if author == "" {
234 author = strings.TrimSpace(orphan.AuthorEmail)
235 }
236 if author == "" {
237 author = "(unknown author)"
238 }
239 if author != lastAuthor {
240 u.Err().Linef("%s", author)
241 lastAuthor = author
242 }
243 u.Err().Linef(" %s\t%s\t%s",
244 orphan.CommentID,
245 truncateString(oneLineTSV(orphan.Content), 80),
246 truncateString(oneLineTSV(orphan.Quote), 60),
247 )
248 }
249 return &ExitError{Code: exitCodeOrphaned, Err: nil}
250}

Calls 8

IsJSONFunction · 0.92
WriteJSONFunction · 0.92
FromContextFunction · 0.92
stdoutWriterFunction · 0.85
truncateStringFunction · 0.85
oneLineTSVFunction · 0.85
LinefMethod · 0.80
ErrMethod · 0.80