MCPcopy Create free account
hub / github.com/ZingerLittleBee/ServerBee / openMenu

Function openMenu

scripts/make-menu.ts:589–627  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

587}
588
589const openMenu = async (): Promise<CommandDefinition | undefined> => {
590 ensureFzfIsInstalled()
591
592 const recentCommands = await readRecentCommands()
593 const menuCommands = orderCommandsForMenu(getFeaturedCommands(), recentCommands)
594 const widths = getMenuColumnWidths(menuCommands)
595 const menuInput = menuCommands.map((command) => formatMenuLine(command, widths, recentCommands)).join('\n')
596
597 const previewCommand = String.raw`printf '%s\n' {5}`
598 const result = spawnSync(
599 'fzf',
600 [
601 '--ansi',
602 '--delimiter',
603 '\t',
604 '--with-nth',
605 '1',
606 '--preview',
607 previewCommand,
608 '--preview-window',
609 'down,3,wrap',
610 '--prompt',
611 'make > ',
612 '--header',
613 'Recent commands are pinned first. * marks commands from history.'
614 ],
615 {
616 cwd: ROOT_DIRECTORY,
617 input: menuInput,
618 encoding: 'utf8',
619 stdio: ['pipe', 'pipe', 'inherit']
620 }
621 )
622
623 return getSelectedCommandFromFzfResult({
624 status: result.status,
625 stdout: result.stdout
626 })
627}
628
629const runShellCommand = async (command: CommandDefinition): Promise<number> => {
630 await recordRecentCommand(HISTORY_PATH, command.key, Date.now())

Callers 1

mainFunction · 0.85

Calls 7

ensureFzfIsInstalledFunction · 0.85
readRecentCommandsFunction · 0.85
orderCommandsForMenuFunction · 0.85
getFeaturedCommandsFunction · 0.85
getMenuColumnWidthsFunction · 0.85
formatMenuLineFunction · 0.85

Tested by

no test coverage detected