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

Function findMatchingSubmitCommand

src/session/replSubmitDispatch.ts:112–131  ·  view source on GitHub ↗
(
  input: string,
  submitState: ReplSubmitState,
  commands: Command[],
  isCommandEnabled: (command: Command) => boolean,
)

Source from the content-addressed store, hash-verified

110}
111
112function findMatchingSubmitCommand(
113 input: string,
114 submitState: ReplSubmitState,
115 commands: Command[],
116 isCommandEnabled: (command: Command) => boolean,
117): Command | undefined {
118 const submittedCommandName = submitState.isSlashCommand
119 ? input.trim().slice(1).split(/\s/)[0]
120 : undefined
121
122 return submittedCommandName
123 ? commands.find(
124 command =>
125 isCommandEnabled(command) &&
126 (command.name === submittedCommandName ||
127 command.aliases?.includes(submittedCommandName) ||
128 getCommandName(command) === submittedCommandName),
129 )
130 : undefined
131}
132
133export async function dispatchReplSubmit(
134 {

Callers 1

dispatchReplSubmitFunction · 0.85

Calls 2

isCommandEnabledFunction · 0.85
getCommandNameFunction · 0.50

Tested by

no test coverage detected