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

Function handleClear

packages/cli/src/internal/prompt/file.ts:88–107  ·  view source on GitHub ↗
(options: FileOptions)

Source from the content-addressed store, hash-verified

86}
87
88function handleClear(options: FileOptions) {
89 return (state: State, _: Prompt.Prompt.Action<State, string>) => {
90 return Effect.gen(function*() {
91 const terminal = yield* Terminal.Terminal
92 const columns = yield* terminal.columns
93 const currentPath = yield* resolveCurrentPath(state.path, options)
94 const text = "\n".repeat(Math.min(state.files.length, options.maxPerPage))
95 const clearPath = InternalAnsiUtils.eraseText(currentPath, columns)
96 const message = showConfirmation(state.confirm) ? CONFIRM_MESSAGE : options.message
97 const clearPrompt = InternalAnsiUtils.eraseText(`\n${message}`, columns)
98 const clearOptions = InternalAnsiUtils.eraseText(text, columns)
99 return clearOptions.pipe(
100 Doc.cat(clearPath),
101 Doc.cat(clearPrompt),
102 Optimize.optimize(Optimize.Deep),
103 Doc.render({ style: "pretty", options: { lineWidth: columns } })
104 )
105 })
106 }
107}
108
109const NEWLINE_REGEX = /\r?\n/
110

Callers 1

fileFunction · 0.70

Calls 2

resolveCurrentPathFunction · 0.85
pipeMethod · 0.65

Tested by

no test coverage detected