MCPcopy Create free account
hub / github.com/kiibohd/controller / CLI_commandLookup

Function CLI_commandLookup

Debug/cli/cli.c:384–420  ·  view source on GitHub ↗

Scans the CLILineBuffer for any valid commands

Source from the content-addressed store, hash-verified

382
383// Scans the CLILineBuffer for any valid commands
384void CLI_commandLookup()
385{
386 // Ignore command if buffer is 0 length
387 if ( CLILineBufferCurrent == 0 )
388 return;
389
390 // Set the last+1 character of the buffer to NULL for string processing
391 CLILineBuffer[CLILineBufferCurrent] = '\0';
392
393 // Retrieve pointers to command and beginning of arguments
394 // Places a NULL at the first space after the command
395 char* cmdPtr;
396 char* argPtr;
397 CLI_argumentIsolation( CLILineBuffer, &cmdPtr, &argPtr );
398
399 // Scan array of dictionaries for a valid command match
400 for ( uint8_t dict = 0; dict < CLIDictionariesUsed; dict++ )
401 {
402 // Parse each cmd until a null command entry is found, or an argument match
403 for ( uint8_t cmd = 0; CLIDict[dict][cmd].name != 0; cmd++ )
404 {
405 // Compare the first argument and each command entry
406 if ( eqStr( cmdPtr, (char*)CLIDict[dict][cmd].name ) == -1 )
407 {
408 // Run the specified command function pointer
409 // argPtr is already pointing at the first character of the arguments
410 (*(void (*)(char*))CLIDict[dict][cmd].function)( argPtr );
411
412 return;
413 }
414 }
415 }
416
417 // No match for the command...
418 print( NL );
419 erro_dPrint("\"", CLILineBuffer, "\" is not a valid command...type \033[35mhelp\033[0m");
420}
421
422// Registers a command dictionary with the CLI
423void CLI_registerDictionary( const CLIDictItem *cmdDict, const char* dictName )

Callers 1

CLI_processFunction · 0.85

Calls 2

CLI_argumentIsolationFunction · 0.85
eqStrFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…