MCPcopy Create free account
hub / github.com/Effect-TS/effect / handleFileClear

Function handleFileClear

packages/effect/src/cli/Prompt.ts:2358–2391  ·  view source on GitHub ↗
(options: FileOptionsReq)

Source from the content-addressed store, hash-verified

2356}
2357
2358const handleFileClear = (options: FileOptionsReq) => {
2359 return Effect.fnUntraced(function*(state: FileState, _: Action<FileState, string>) {
2360 const terminal = yield* Terminal.Terminal
2361 const columns = yield* terminal.columns
2362 const path = yield* Path.Path
2363 const figures = yield* getTheme(options)
2364 const currentPath = yield* resolveCurrentPath(state.path, options)
2365 const selectedPath = state.files[state.cursor]
2366 const resolvedPath = selectedPath === undefined ? currentPath : path.resolve(currentPath, selectedPath)
2367 const resolvedPathText = separateSymbol(figures.pointerSmall, resolvedPath)
2368 const isConfirming = showConfirmation(state.confirm)
2369 const promptText = isConfirming
2370 ? renderPrompt("(Y/n)", CONFIRM_MESSAGE, figures.prefix, figures.pointerSmall, figures, { plain: true })
2371 : renderPrompt(
2372 renderFileFilter(state, figures, { plain: true }),
2373 options.message,
2374 figures.tick,
2375 figures.ellipsis,
2376 figures,
2377 {
2378 plain: true
2379 }
2380 )
2381 const filesText = isConfirming
2382 ? ""
2383 : renderFiles(state, state.files, figures, options, { plain: true })
2384 const outputText = isConfirming
2385 ? `${promptText}\n${resolvedPathText}`
2386 : `${promptText}\n${resolvedPathText}\n${filesText}`
2387 const clearOutput = eraseText(outputText, columns)
2388 const resetCurrentLine = Ansi.eraseLine + Ansi.cursorLeft
2389 return clearOutput + resetCurrentLine
2390 })
2391}
2392
2393type RenderOptions = {
2394 readonly plain?: boolean

Callers 1

FileFunction · 0.85

Calls 8

getThemeFunction · 0.85
resolveCurrentPathFunction · 0.85
separateSymbolFunction · 0.85
renderPromptFunction · 0.85
renderFileFilterFunction · 0.85
renderFilesFunction · 0.85
eraseTextFunction · 0.85
resolveMethod · 0.80

Tested by

no test coverage detected