/** * argc = the exact number of args, don't include the command name * example: argc = 2, argv = {"Hello", "World"} * * expectedResult true means the execute function is called */ static void dispatchCommand(const char *command_string, int argc, char **argv, bool expectedResult) { MetisCommandParser *parser = metisCommandParser_Create(); bool execute_called = false; MetisCommandOps *ops = metisCommandOps_Create(&execute_called, command_string, NULL, test_execute, metisCommandOps_Destroy); PARCList *args = parcList(parcArrayList_Create(NULL), PARCArrayListAsPARCList); parcList_AddAll(args, argc, (void **) &argv[0]); execute_called = false; metisCommandParser_RegisterCommand(parser, ops); metisCommandParser_DispatchCommand(parser, args); if (expectedResult) { assertTrue(execute_called, "Did not call the execute function"); } else { assertFalse(execute_called, "The execute function should not have been called but was"); } metisCommandParser_Destroy(&parser); parcList_Release(&args); }
MetisCommandOps * metisControlRemoveRoute_HelpCreate(MetisControlState *state) { return metisCommandOps_Create(state, _commandRemoveRouteHelp, NULL, _metisControlRemoveRoute_HelpExecute, metisCommandOps_Destroy); }