[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 <[email protected]>
This commit is contained in:
Robert Lubos
2021-11-26 22:58:28 -08:00
committed by GitHub
parent 428944b1f6
commit e4da1f6c71
2 changed files with 15 additions and 0 deletions
+2
View File
@@ -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)
+13
View File
@@ -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_