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

Function cli_set_default_command_handler

cli/cli.c:900–921  ·  view source on GitHub ↗

* @brief Sets the default command handler for the parser. * * This function allows setting a default command handler that will be invoked * when no specific command is found in the arguments. The handler can be cleared * by passing NULL. * * @param parser A pointer to the `CliParser` instance. Must not be NULL. * @param handler The function to be set as the default command handler. Can be N

Source from the content-addressed store, hash-verified

898 }
899 }
900 return NULL;
901}
902
903static CliOption* cli_find_short_option(CliOption* opts, size_t n, char c) {
904 for (size_t k = 0; k < n; ++k) {
905 if (opts[k].shortOpt && opts[k].shortOpt == c) {
906 return &opts[k];
907 }
908 }
909 return NULL;
910}
911
912/* Value for an option that takes one: an attached value ("--o=v", "-ov"),
913 * else, for CLI_REQUIRED_ARG only, the next token if it is not itself an
914 * option. A CLI_OPTIONAL_ARG never takes the next token (it used to swallow
915 * a following command or option). Returns false when a required value is
916 * missing. */
917static bool cli_option_value(const CliOption* o, const char* attached, int argc, char* argv[], int* i, const char** value) {
918 *value = NULL;
919 if (attached) {
920 *value = attached;
921 return true;
922 }
923 if (o->optionType == CLI_REQUIRED_ARG) {
924 if (*i + 1 < argc && !cli_is_option_token(argv[*i + 1])) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected