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

Function handleClear

packages/cli/src/internal/prompt/date.ts:26–48  ·  view source on GitHub ↗
(options: DateOptions)

Source from the content-addressed store, hash-verified

24const renderBeep = Doc.render(Doc.beep, { style: "pretty" })
25
26function handleClear(options: DateOptions) {
27 return (state: State, _: Prompt.Prompt.Action<State, globalThis.Date>) => {
28 return Effect.gen(function*() {
29 const terminal = yield* Terminal.Terminal
30 const columns = yield* terminal.columns
31 const resetCurrentLine = Doc.cat(Doc.eraseLine, Doc.cursorLeft)
32 const clearError = Option.match(state.error, {
33 onNone: () => Doc.empty,
34 onSome: (error) =>
35 Doc.cursorDown(InternalAnsiUtils.lines(error, columns)).pipe(
36 Doc.cat(InternalAnsiUtils.eraseText(`\n${error}`, columns))
37 )
38 })
39 const clearOutput = InternalAnsiUtils.eraseText(options.message, columns)
40 return clearError.pipe(
41 Doc.cat(clearOutput),
42 Doc.cat(resetCurrentLine),
43 Optimize.optimize(Optimize.Deep),
44 Doc.render({ style: "pretty", options: { lineWidth: columns } })
45 )
46 })
47 }
48}
49
50const NEWLINE_REGEX = /\r?\n/
51

Callers 1

dateFunction · 0.70

Calls 1

pipeMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…