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

Function handleFileClear

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

Source from the content-addressed store, hash-verified

2194}
2195
2196const handleFileClear = (options: FileOptionsReq) => {
2197 return Effect.fnUntraced(function*(state: FileState, _: Action<FileState, string>) {
2198 const terminal = yield* Terminal.Terminal
2199 const columns = yield* terminal.columns
2200 const path = yield* Path.Path
2201 const figures = yield* platformFigures
2202 const currentPath = yield* resolveCurrentPath(state.path, options)
2203 const selectedPath = state.files[state.cursor]
2204 const resolvedPath = selectedPath === undefined ? currentPath : path.resolve(currentPath, selectedPath)
2205 const resolvedPathText = `${figures.pointerSmall} ${resolvedPath}`
2206 const isConfirming = showConfirmation(state.confirm)
2207 const promptText = isConfirming
2208 ? renderPrompt("(Y/n)", CONFIRM_MESSAGE, "?", figures.pointerSmall, { plain: true })
2209 : renderPrompt(renderFileFilter(state, { plain: true }), options.message, figures.tick, figures.ellipsis, {
2210 plain: true
2211 })
2212 const filesText = isConfirming
2213 ? ""
2214 : renderFiles(state, state.files, figures, options, { plain: true })
2215 const outputText = isConfirming
2216 ? `${promptText}\n${resolvedPathText}`
2217 : `${promptText}\n${resolvedPathText}\n${filesText}`
2218 const clearOutput = eraseText(outputText, columns)
2219 const resetCurrentLine = Ansi.eraseLine + Ansi.cursorLeft
2220 return clearOutput + resetCurrentLine
2221 })
2222}
2223
2224type RenderOptions = {
2225 readonly plain?: boolean

Callers 1

fileFunction · 0.85

Calls 5

resolveCurrentPathFunction · 0.85
renderPromptFunction · 0.85
renderFileFilterFunction · 0.85
renderFilesFunction · 0.85
eraseTextFunction · 0.85

Tested by

no test coverage detected