From e4da1f6c71c2c62e6932966649867b47cbd674cd Mon Sep 17 00:00:00 2001 From: Robert Lubos Date: Sat, 27 Nov 2021 07:58:28 +0100 Subject: [PATCH] [cli] add option to disable prompt (#7209) When running OT CLI in Zephyr, it's not desired to print a prompt after executing a command, as OT CLI is tightly integrated with Zephyr shell module which provides its own prompt. Add a config option which allows to disable CLI prompt on the output. Signed-off-by: Robert Lubos --- src/cli/cli.cpp | 2 ++ src/cli/cli_config.h | 13 +++++++++++++ 2 files changed, 15 insertions(+) diff --git a/src/cli/cli.cpp b/src/cli/cli.cpp index 05602c867..d882d2209 100644 --- a/src/cli/cli.cpp +++ b/src/cli/cli.cpp @@ -4976,6 +4976,7 @@ void Interpreter::Initialize(otInstance *aInstance, otCliOutputCallback aCallbac void Interpreter::OutputPrompt(void) { +#if OPENTHREAD_CONFIG_CLI_PROMPT_ENABLE static const char sPrompt[] = "> "; // The `OutputFormat()` below is adding the prompt which is not @@ -4986,6 +4987,7 @@ void Interpreter::OutputPrompt(void) SetEmittingCommandOutput(false); OutputFormat("%s", sPrompt); SetEmittingCommandOutput(true); +#endif // OPENTHREAD_CONFIG_CLI_PROMPT_ENABLE } void Interpreter::HandleTimer(Timer &aTimer) diff --git a/src/cli/cli_config.h b/src/cli/cli_config.h index 96148e3db..36aedc644 100644 --- a/src/cli/cli_config.h +++ b/src/cli/cli_config.h @@ -113,4 +113,17 @@ #define OPENTHREAD_CONFIG_CLI_LOG_INPUT_OUTPUT_LOG_STRING_SIZE OPENTHREAD_CONFIG_CLI_MAX_LINE_LENGTH #endif +/** + * @def OPENTHREAD_CONFIG_CLI_PROMPT_ENABLE + * + * Enable CLI prompt. + * + * When enabled, the CLI will print prompt on the output after processing a command. + * Otherwise, no prompt is added to the output. + * + */ +#ifndef OPENTHREAD_CONFIG_CLI_PROMPT_ENABLE +#define OPENTHREAD_CONFIG_CLI_PROMPT_ENABLE 1 +#endif + #endif // CONFIG_CLI_H_