MCPcopy Create free account
hub / github.com/Effect-TS/effect / renderOutput

Function renderOutput

packages/cli/src/internal/prompt/multi-select.ts:28–47  ·  view source on GitHub ↗
(
  leadingSymbol: Doc.AnsiDoc,
  trailingSymbol: Doc.AnsiDoc,
  options: SelectOptions<A>
)

Source from the content-addressed store, hash-verified

26const NEWLINE_REGEX = /\r?\n/
27
28function renderOutput<A>(
29 leadingSymbol: Doc.AnsiDoc,
30 trailingSymbol: Doc.AnsiDoc,
31 options: SelectOptions<A>
32) {
33 const annotateLine = (line: string): Doc.AnsiDoc => Doc.annotate(Doc.text(line), Ansi.bold)
34 const prefix = Doc.cat(leadingSymbol, Doc.space)
35 return Arr.match(options.message.split(NEWLINE_REGEX), {
36 onEmpty: () => Doc.hsep([prefix, trailingSymbol]),
37 onNonEmpty: (promptLines) => {
38 const lines = Arr.map(promptLines, (line) => annotateLine(line))
39 return prefix.pipe(
40 Doc.cat(Doc.nest(Doc.vsep(lines), 2)),
41 Doc.cat(Doc.space),
42 Doc.cat(trailingSymbol),
43 Doc.cat(Doc.space)
44 )
45 }
46 })
47}
48
49function renderError(state: State, pointer: Doc.AnsiDoc) {
50 return Option.match(state.error, {

Callers 2

renderNextFrameFunction · 0.70
renderSubmissionFunction · 0.70

Calls 4

splitMethod · 0.80
annotateLineFunction · 0.70
mapMethod · 0.65
pipeMethod · 0.65

Tested by

no test coverage detected