mirror of
https://github.com/espressif/openthread.git
synced 2026-08-07 19:27:46 +00:00
[cli] misc enhancements (#5528)
This commit contains a group of smaller enhancements in Cli modules:
- Add and use OutputLine() helper method which outputs a formatted
string line (appends newline \r\n).
- Use binary search when finding the command in sCommands array (also
adds static_assert check to ensure sCommands array is sorted).
- Define Command struct as a private nested type.
- Use enum constants (replacing #define).
- Rename method to OutputResult() (from AppendResult) to harmonize
with rest of a Output{Something}() methods.
- Remove comments at #endif when within 20 lines of #if
This commit is contained in:
+3
-3
@@ -66,7 +66,7 @@ otError UdpExample::ProcessHelp(uint8_t aArgsLength, char *aArgs[])
|
||||
|
||||
for (const Command &command : sCommands)
|
||||
{
|
||||
mInterpreter.OutputFormat("%s\r\n", command.mName);
|
||||
mInterpreter.OutputLine("%s", command.mName);
|
||||
}
|
||||
|
||||
return OT_ERROR_NONE;
|
||||
@@ -241,7 +241,7 @@ otError UdpExample::ProcessLinkSecurity(uint8_t aArgsLength, char *aArgs[])
|
||||
|
||||
if (aArgsLength == 0)
|
||||
{
|
||||
mInterpreter.OutputFormat("%s\r\n", mLinkSecurityEnabled ? "Enabled" : "Disabled");
|
||||
mInterpreter.OutputLine("%s", mLinkSecurityEnabled ? "Enabled" : "Disabled");
|
||||
}
|
||||
else if (strcmp(aArgs[0], "enable") == 0)
|
||||
{
|
||||
@@ -327,7 +327,7 @@ void UdpExample::HandleUdpReceive(otMessage *aMessage, const otMessageInfo *aMes
|
||||
length = otMessageRead(aMessage, otMessageGetOffset(aMessage), buf, sizeof(buf) - 1);
|
||||
buf[length] = '\0';
|
||||
|
||||
mInterpreter.OutputFormat("%s\r\n", buf);
|
||||
mInterpreter.OutputLine("%s", buf);
|
||||
}
|
||||
|
||||
} // namespace Cli
|
||||
|
||||
Reference in New Issue
Block a user