( leadingSymbol: Doc.AnsiDoc, trailingSymbol: Doc.AnsiDoc, options: SelectOptions<A> )
| 26 | const NEWLINE_REGEX = /\r?\n/ |
| 27 | |
| 28 | function 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 | |
| 49 | function renderError(state: State, pointer: Doc.AnsiDoc) { |
| 50 | return Option.match(state.error, { |
no test coverage detected