MCPcopy Create free account
hub / github.com/KaisenAmin/c_std / cli_set_error_handler

Function cli_set_error_handler

cli/cli.c:297–313  ·  view source on GitHub ↗

* @brief Sets a custom error handler for the CLI parser. * * This function allows the user to specify a custom error handler function that will be called whenever * an error occurs during parsing. The custom handler can be used to provide custom error messages or * perform specific error handling actions. * * @param parser A pointer to the `CliParser` instance. Must not be NULL. * @param ha

Source from the content-addressed store, hash-verified

295 cli_last_error.code = CLI_SUCCESS;
296
297 CLI_LOG("[cli_parser_deallocate] %s", cli_last_error.message);
298}
299
300
301/**
302 * @brief Sets a custom usage message for the CLI parser.
303 *
304 * This function allows the user to set a custom usage message that will be displayed
305 * when help information is printed. The custom usage message overrides the default
306 * generated message.
307 *
308 * @param parser A pointer to the `CliParser` instance. Must not be NULL.
309 * @param usage A string containing the custom usage message. Must not be NULL.
310 *
311 * @return void
312 * @note If the `parser` or `usage` is NULL, an error is logged and the function returns without setting the usage message.
313 */
314void cli_set_custom_usage(CliParser *parser, const char *usage) {
315 if (parser == NULL || usage == NULL) {
316 snprintf(cli_last_error.message, sizeof(cli_last_error.message), "Error: NULL argument provided to cli_set_custom_usage.\n");

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected