(options: Options)
| 257 | } |
| 258 | |
| 259 | function handleProcess(options: Options) { |
| 260 | return (input: Terminal.UserInput, state: State) => { |
| 261 | switch (input.key.name) { |
| 262 | case "backspace": { |
| 263 | return processBackspace(state) |
| 264 | } |
| 265 | case "left": { |
| 266 | return processCursorLeft(state) |
| 267 | } |
| 268 | case "right": { |
| 269 | return processCursorRight(state) |
| 270 | } |
| 271 | case "enter": |
| 272 | case "return": { |
| 273 | const value = getValue(state, options) |
| 274 | return Effect.match(options.validate(value), { |
| 275 | onFailure: (error) => |
| 276 | Action.NextFrame({ |
| 277 | state: { ...state, value, error: Option.some(error) } |
| 278 | }), |
| 279 | onSuccess: (value) => Action.Submit({ value }) |
| 280 | }) |
| 281 | } |
| 282 | case "tab": { |
| 283 | return processTab(state, options) |
| 284 | } |
| 285 | default: { |
| 286 | const value = Option.getOrElse(input.input, () => "") |
| 287 | return defaultProcessor(value, state) |
| 288 | } |
| 289 | } |
| 290 | } |
| 291 | } |
| 292 | |
| 293 | function handleClear(options: Options) { |
| 294 | return (state: State, _: Prompt.Prompt.Action<State, string>) => { |
no test coverage detected
searching dependent graphs…