[cli] adding helper method ParseEnableOrDisable() (#6426)

This commit adds a helper method `Cli::ParseEnableOrDisable()` which
checks a given string against two common commands "enable" or
"disable". This method is then used in CLI modules.
This commit is contained in:
Abtin Keshavarzian
2021-04-12 07:27:26 -07:00
committed by GitHub
parent f7802d60a1
commit 850468a68a
4 changed files with 70 additions and 114 deletions
+1 -9
View File
@@ -216,17 +216,9 @@ otError UdpExample::ProcessLinkSecurity(uint8_t aArgsLength, char *aArgs[])
{
mInterpreter.OutputEnabledDisabledStatus(mLinkSecurityEnabled);
}
else if (strcmp(aArgs[0], "enable") == 0)
{
mLinkSecurityEnabled = true;
}
else if (strcmp(aArgs[0], "disable") == 0)
{
mLinkSecurityEnabled = false;
}
else
{
error = OT_ERROR_INVALID_COMMAND;
error = Interpreter::ParseEnableOrDisable(aArgs[0], mLinkSecurityEnabled);
}
return error;