MCPcopy Create free account
hub / github.com/Noumena-Network/code / completionHandler

Function completionHandler

src/cli/handlers/ant.ts:875–900  ·  view source on GitHub ↗
(
  shell: string,
  opts: { output?: string } = {},
  program: CommanderCommand,
)

Source from the content-addressed store, hash-verified

873}
874
875export async function completionHandler(
876 shell: string,
877 opts: { output?: string } = {},
878 program: CommanderCommand,
879): Promise<void> {
880 try {
881 const script = generateCompletionScript(shell, program)
882 if (opts.output) {
883 const outputPath = expandPath(opts.output)
884 await mkdir(dirname(outputPath), { recursive: true })
885 await writeFile(outputPath, script, 'utf8')
886 writeToStdout(`Wrote ${shell} completion script to ${outputPath}\n`)
887 } else {
888 writeToStdout(script)
889 if (!script.endsWith('\n')) {
890 writeToStdout('\n')
891 }
892 }
893 await gracefulShutdown(0)
894 } catch (error) {
895 writeToStderr(
896 `Failed to generate completion script: ${errorMessage(error)}\n`,
897 )
898 await gracefulShutdown(1)
899 }
900}

Callers 1

runFunction · 0.85

Calls 7

generateCompletionScriptFunction · 0.85
expandPathFunction · 0.85
mkdirFunction · 0.85
writeToStdoutFunction · 0.85
gracefulShutdownFunction · 0.85
writeToStderrFunction · 0.85
errorMessageFunction · 0.50

Tested by

no test coverage detected