(options: Prompt.Prompt.FileOptions = {})
| 349 | |
| 350 | /** @internal */ |
| 351 | export const file = (options: Prompt.Prompt.FileOptions = {}): Prompt.Prompt<string> => { |
| 352 | const opts: FileOptions = { |
| 353 | type: options.type ?? "file", |
| 354 | message: options.message ?? `Choose a file`, |
| 355 | startingPath: Option.fromNullable(options.startingPath), |
| 356 | maxPerPage: options.maxPerPage ?? 10, |
| 357 | filter: options.filter ?? (() => Effect.succeed(true)) |
| 358 | } |
| 359 | const initialState: Effect.Effect< |
| 360 | State, |
| 361 | never, |
| 362 | Prompt.Prompt.Environment |
| 363 | > = Effect.gen(function*() { |
| 364 | const path = Option.none<string>() |
| 365 | const currentPath = yield* resolveCurrentPath(path, opts) |
| 366 | const files = yield* getFileList(currentPath, opts) |
| 367 | const confirm = Confirm.Hide() |
| 368 | return { cursor: 0, files, path, confirm } |
| 369 | }) |
| 370 | return InternalPrompt.custom(initialState, { |
| 371 | render: handleRender(opts), |
| 372 | process: handleProcess(opts), |
| 373 | clear: handleClear(opts) |
| 374 | }) |
| 375 | } |
nothing calls this directly
no test coverage detected