MCPcopy Index your code
hub / github.com/claude-code-best/claude-code / getCommandSubcommandPrefixImpl

Function getCommandSubcommandPrefixImpl

src/utils/shell/prefix.ts:331–366  ·  view source on GitHub ↗
(
  command: string,
  abortSignal: AbortSignal,
  isNonInteractiveSession: boolean,
  getPrefix: ReturnType<typeof createCommandPrefixExtractor>,
  splitCommandFn: (command: string) => string[] | Promise<string[]>,
)

Source from the content-addressed store, hash-verified

329}
330
331async function getCommandSubcommandPrefixImpl(
332 command: string,
333 abortSignal: AbortSignal,
334 isNonInteractiveSession: boolean,
335 getPrefix: ReturnType<typeof createCommandPrefixExtractor>,
336 splitCommandFn: (command: string) => string[] | Promise<string[]>,
337): Promise<CommandSubcommandPrefixResult | null> {
338 const subcommands = await splitCommandFn(command)
339
340 const [fullCommandPrefix, ...subcommandPrefixesResults] = await Promise.all([
341 getPrefix(command, abortSignal, isNonInteractiveSession),
342 ...subcommands.map(async subcommand => ({
343 subcommand,
344 prefix: await getPrefix(subcommand, abortSignal, isNonInteractiveSession),
345 })),
346 ])
347
348 if (!fullCommandPrefix) {
349 return null
350 }
351
352 const subcommandPrefixes = subcommandPrefixesResults.reduce(
353 (acc, { subcommand, prefix }) => {
354 if (prefix) {
355 acc.set(subcommand, prefix)
356 }
357 return acc
358 },
359 new Map<string, CommandPrefixResult>(),
360 )
361
362 return {
363 ...fullCommandPrefix,
364 subcommandPrefixes,
365 }
366}

Callers 1

Calls 1

setMethod · 0.80

Tested by

no test coverage detected