drivers/console: shell: Add custom prompt callback support

Shell applications may want to have a dynamic prompt rather than a
fixed string. Add a new API to let the application specify a custom
callback instead of using the fixed string given to shell_init().

Change-Id: I9844481057fc8e164530a677e7cb1bfb6d02cfc0
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This commit is contained in:
Johan Hedberg 2015-12-04 13:10:36 +02:00 committed by Anas Nashif
commit 2893def459
2 changed files with 32 additions and 1 deletions

View file

@ -42,3 +42,14 @@ void shell_init(const char *prompt, struct shell_cmd *cmds);
*/
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);