MCPcopy Index your code
hub / github.com/Effect-TS/effect / file

Function file

packages/cli/src/internal/prompt/file.ts:351–375  ·  view source on GitHub ↗
(options: Prompt.Prompt.FileOptions = {})

Source from the content-addressed store, hash-verified

349
350/** @internal */
351export 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}

Callers

nothing calls this directly

Calls 5

resolveCurrentPathFunction · 0.85
getFileListFunction · 0.85
handleRenderFunction · 0.70
handleProcessFunction · 0.70
handleClearFunction · 0.70

Tested by

no test coverage detected