/* shell.h - Shell header */ /* * Copyright (c) 2015 Intel Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** @brief Callback called when command is entered. * * @param argc Number of parameters passed. * @param argv Array of option strings. First option is always command name. */ typedef void (*shell_cmd_function_t)(int argc, char *argv[]); struct shell_cmd { const char *cmd_name; shell_cmd_function_t cb; }; /** @brief Initialize shell with optional prompt, NULL in case no prompt is * needed. * * @param prompt Prompt to be printed on serial console. * @param cmds Commands to register */ void shell_init(const char *prompt, struct shell_cmd *cmds); /** @brief Optionally register an app default cmd handler. * * @param handler To be called if no cmd found in cmds registered with shell_init. */ void shell_register_app_cmd_handler(shell_cmd_function_t handler); /** @brief Callback to get the current prompt. * * @returns Current prompt string. */ typedef const char *(*shell_prompt_function_t)(void); /** @brief Optionally register a custom prompt callback. * * @param handler To be called to get the current prompt. */ void shell_register_prompt_handler(shell_prompt_function_t handler);