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

Function handleProcess

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

Source from the content-addressed store, hash-verified

294}
295
296function handleProcess(options: FileOptions) {
297 return (input: Terminal.UserInput, state: State) =>
298 Effect.gen(function*() {
299 switch (input.key.name) {
300 case "k":
301 case "up": {
302 return yield* processCursorUp(state)
303 }
304 case "j":
305 case "down":
306 case "tab": {
307 return yield* processCursorDown(state)
308 }
309 case "enter":
310 case "return": {
311 return yield* processSelection(state, options)
312 }
313 case "y":
314 case "t": {
315 if (showConfirmation(state.confirm)) {
316 const path = yield* Path.Path
317 const currentPath = yield* resolveCurrentPath(state.path, options)
318 const selectedPath = state.files[state.cursor]
319 const resolvedPath = path.resolve(currentPath, selectedPath)
320 const files = yield* getFileList(resolvedPath, options)
321 return Action.NextFrame({
322 state: {
323 cursor: 0,
324 files,
325 path: Option.some(resolvedPath),
326 confirm: Confirm.Hide()
327 }
328 })
329 }
330 return Action.Beep()
331 }
332 case "n":
333 case "f": {
334 if (showConfirmation(state.confirm)) {
335 const path = yield* Path.Path
336 const currentPath = yield* resolveCurrentPath(state.path, options)
337 const selectedPath = state.files[state.cursor]
338 const resolvedPath = path.resolve(currentPath, selectedPath)
339 return Action.Submit({ value: resolvedPath })
340 }
341 return Action.Beep()
342 }
343 default: {
344 return Action.Beep()
345 }
346 }
347 })
348}
349
350/** @internal */
351export const file = (options: Prompt.Prompt.FileOptions = {}): Prompt.Prompt<string> => {

Callers 1

fileFunction · 0.70

Calls 5

processSelectionFunction · 0.85
resolveCurrentPathFunction · 0.85
getFileListFunction · 0.85
processCursorUpFunction · 0.70
processCursorDownFunction · 0.70

Tested by

no test coverage detected