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

Function handleFileProcess

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

Source from the content-addressed store, hash-verified

2432})
2433
2434const handleFileProcess = (options: FileOptionsReq) => {
2435 return Effect.fnUntraced(function*(input: Terminal.UserInput, state: FileState) {
2436 if (input.key.ctrl) {
2437 if (input.key.name === "u") {
2438 if (showConfirmation(state.confirm)) {
2439 return Action.Beep()
2440 }
2441 return yield* processFileClear(state)
2442 }
2443 return Action.Beep()
2444 }
2445 switch (input.key.name) {
2446 case "k":
2447 case "up": {
2448 return yield* processFileCursorUp(state)
2449 }
2450 case "j":
2451 case "down":
2452 case "tab": {
2453 return yield* processFileCursorDown(state)
2454 }
2455 case "backspace": {
2456 if (showConfirmation(state.confirm)) {
2457 return Action.Beep()
2458 }
2459 return yield* processFileBackspace(state)
2460 }
2461 case "enter":
2462 case "return": {
2463 return yield* processSelection(state, options)
2464 }
2465 case "y":
2466 case "t": {
2467 if (showConfirmation(state.confirm)) {
2468 const path = yield* Path.Path
2469 const currentPath = yield* resolveCurrentPath(state.path, options)
2470 const selectedPath = state.files[state.cursor]
2471 const resolvedPath = path.resolve(currentPath, selectedPath)
2472 const files = yield* getFileList(resolvedPath, options)
2473 return Action.NextFrame({
2474 state: {
2475 cursor: 0,
2476 files,
2477 allFiles: files,
2478 query: "",
2479 path: Option.some(resolvedPath),
2480 confirm: Confirm.Hide()
2481 }
2482 })
2483 }
2484 return yield* processFileInput(Option.getOrElse(input.input, () => ""), state)
2485 }
2486 case "n":
2487 case "f": {
2488 if (showConfirmation(state.confirm)) {
2489 const path = yield* Path.Path
2490 const currentPath = yield* resolveCurrentPath(state.path, options)
2491 const selectedPath = state.files[state.cursor]

Callers 1

fileFunction · 0.85

Calls 7

processFileClearFunction · 0.85
processFileCursorUpFunction · 0.85
processFileCursorDownFunction · 0.85
processFileBackspaceFunction · 0.85
resolveCurrentPathFunction · 0.85
processFileInputFunction · 0.85
someMethod · 0.80

Tested by

no test coverage detected