MCPcopy Create free account
hub / github.com/F-Stack/f-stack / FindCommand

Function FindCommand

tools/ngctl/main.c:524–543  ·  view source on GitHub ↗

* Find a command */

Source from the content-addressed store, hash-verified

522 * Find a command
523 */
524static const struct ngcmd *
525FindCommand(const char *string)
526{
527 int k, found = -1;
528
529 for (k = 0; cmds[k] != NULL; k++) {
530 if (MatchCommand(cmds[k], string)) {
531 if (found != -1) {
532 warnx("\"%s\": ambiguous command", string);
533 return (NULL);
534 }
535 found = k;
536 }
537 }
538 if (found == -1) {
539 warnx("\"%s\": unknown command", string);
540 return (NULL);
541 }
542 return (cmds[found]);
543}
544
545/*
546 * See if string matches a prefix of "cmd" (or an alias) case insensitively

Callers 2

DoCommandFunction · 0.85
HelpCmdFunction · 0.85

Calls 1

MatchCommandFunction · 0.85

Tested by

no test coverage detected