(nextState: State, options: Options, submitted: boolean)
| 64 | } |
| 65 | |
| 66 | function renderInput(nextState: State, options: Options, submitted: boolean) { |
| 67 | const text = getValue(nextState, options) |
| 68 | |
| 69 | const annotation = Option.match(nextState.error, { |
| 70 | onNone: () => { |
| 71 | if (submitted) { |
| 72 | return Ansi.white |
| 73 | } |
| 74 | |
| 75 | if (nextState.value.length === 0) { |
| 76 | return Ansi.blackBright |
| 77 | } |
| 78 | |
| 79 | return Ansi.combine(Ansi.underlined, Ansi.cyanBright) |
| 80 | }, |
| 81 | onSome: () => Ansi.red |
| 82 | }) |
| 83 | |
| 84 | switch (options.type) { |
| 85 | case "hidden": { |
| 86 | return Doc.empty |
| 87 | } |
| 88 | case "password": { |
| 89 | return Doc.annotate(Doc.text("*".repeat(text.length)), annotation) |
| 90 | } |
| 91 | case "text": { |
| 92 | return Doc.annotate(Doc.text(text), annotation) |
| 93 | } |
| 94 | } |
| 95 | } |
| 96 | |
| 97 | function renderError(nextState: State, pointer: Doc.AnsiDoc) { |
| 98 | return Option.match(nextState.error, { |
no test coverage detected