(state: State, pointer: Doc.AnsiDoc)
| 47 | } |
| 48 | |
| 49 | function renderError(state: State, pointer: Doc.AnsiDoc) { |
| 50 | return Option.match(state.error, { |
| 51 | onNone: () => Doc.empty, |
| 52 | onSome: (error) => |
| 53 | Arr.match(error.split(NEWLINE_REGEX), { |
| 54 | onEmpty: () => Doc.empty, |
| 55 | onNonEmpty: (errorLines) => { |
| 56 | const annotateLine = (line: string): Doc.AnsiDoc => |
| 57 | Doc.annotate(Doc.text(line), Ansi.combine(Ansi.italicized, Ansi.red)) |
| 58 | const prefix = Doc.cat(Doc.annotate(pointer, Ansi.red), Doc.space) |
| 59 | const lines = Arr.map(errorLines, (str) => annotateLine(str)) |
| 60 | return Doc.cursorSavePosition.pipe( |
| 61 | Doc.cat(Doc.hardLine), |
| 62 | Doc.cat(prefix), |
| 63 | Doc.cat(Doc.align(Doc.vsep(lines))), |
| 64 | Doc.cat(Doc.cursorRestorePosition) |
| 65 | ) |
| 66 | } |
| 67 | }) |
| 68 | }) |
| 69 | } |
| 70 | |
| 71 | function renderChoiceDescription<A>( |
| 72 | choice: Prompt.Prompt.SelectChoice<A>, |
no test coverage detected