shell: Allow extension of shell APIs
Similar to logging module, allow application specific extension of shell fprintf APIs at a macro level. Signed-off-by: Al Semjonovs <asemjonovs@google.com>
This commit is contained in:
parent
30b122b3f0
commit
0bca04635d
|
@ -1008,9 +1008,10 @@ int shell_stop(const struct shell *sh);
|
|||
* @param[in] fmt Format string.
|
||||
* @param[in] ... List of parameters to print.
|
||||
*/
|
||||
void __printf_like(3, 4) shell_fprintf(const struct shell *sh,
|
||||
enum shell_vt100_color color,
|
||||
const char *fmt, ...);
|
||||
void __printf_like(3, 4) shell_fprintf_impl(const struct shell *sh, enum shell_vt100_color color,
|
||||
const char *fmt, ...);
|
||||
|
||||
#define shell_fprintf(sh, color, fmt, ...) shell_fprintf_impl(sh, color, fmt, ##__VA_ARGS__)
|
||||
|
||||
/**
|
||||
* @brief vprintf-like function which sends formatted data stream to the shell.
|
||||
|
@ -1277,4 +1278,9 @@ int shell_get_return_value(const struct shell *sh);
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_SHELL_CUSTOM_HEADER
|
||||
/* This include must always be at the end of shell.h */
|
||||
#include <zephyr_custom_shell.h>
|
||||
#endif
|
||||
|
||||
#endif /* SHELL_H__ */
|
||||
|
|
|
@ -297,6 +297,14 @@ config SHELL_CMDS_RETURN_VALUE
|
|||
This option enables the retval command. It is used to retrieve
|
||||
the return value from the most recently executed command.
|
||||
|
||||
config SHELL_CUSTOM_HEADER
|
||||
bool "Include Custom Shell Header"
|
||||
help
|
||||
When enabled, a custom application provided header, named
|
||||
"zephyr_custom_shell.h", is included at the end of shell.h. This enables
|
||||
extension of the shell APIs at the macro level. Please use cautiously!
|
||||
The internal shell API may change in future releases.
|
||||
|
||||
source "subsys/shell/modules/Kconfig"
|
||||
|
||||
endif # SHELL
|
||||
|
|
|
@ -1548,7 +1548,7 @@ void shell_vfprintf(const struct shell *sh, enum shell_vt100_color color,
|
|||
/* This function mustn't be used from shell context to avoid deadlock.
|
||||
* However it can be used in shell command handlers.
|
||||
*/
|
||||
void shell_fprintf(const struct shell *sh, enum shell_vt100_color color,
|
||||
void shell_fprintf_impl(const struct shell *sh, enum shell_vt100_color color,
|
||||
const char *fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
|
|
Loading…
Reference in New Issue