mirror of
https://github.com/espressif/openthread.git
synced 2026-06-06 05:24:51 +00:00
[cli] enhance parsing of flags for route commands (#8340)
This commit enhances `ParseRoute()` method allowing flags to be specified in one arg (sequence of char indicating different flags) or potentially over different args. This commit also allows `-` to be used in `route` or `prefix` commands to indicate empty flag.
This commit is contained in:
committed by
GitHub
parent
778e3b9ead
commit
1d1e5d16e0
+23
-10
@@ -5539,6 +5539,9 @@ otError Interpreter::ParsePrefix(Arg aArgs[], otBorderRouterConfig &aConfig)
|
||||
aConfig.mDp = true;
|
||||
break;
|
||||
#endif
|
||||
case '-':
|
||||
break;
|
||||
|
||||
default:
|
||||
ExitNow(error = OT_ERROR_INVALID_ARGS);
|
||||
}
|
||||
@@ -5767,21 +5770,31 @@ otError Interpreter::ParseRoute(Arg aArgs[], otExternalRouteConfig &aConfig)
|
||||
{
|
||||
otRoutePreference preference;
|
||||
|
||||
if (*aArgs == "s")
|
||||
{
|
||||
aConfig.mStable = true;
|
||||
}
|
||||
else if (*aArgs == "n")
|
||||
{
|
||||
aConfig.mNat64 = true;
|
||||
}
|
||||
else if (ParsePreference(*aArgs, preference) == OT_ERROR_NONE)
|
||||
if (ParsePreference(*aArgs, preference) == OT_ERROR_NONE)
|
||||
{
|
||||
aConfig.mPreference = preference;
|
||||
}
|
||||
else
|
||||
{
|
||||
ExitNow(error = OT_ERROR_INVALID_ARGS);
|
||||
for (char *arg = aArgs->GetCString(); *arg != '\0'; arg++)
|
||||
{
|
||||
switch (*arg)
|
||||
{
|
||||
case 's':
|
||||
aConfig.mStable = true;
|
||||
break;
|
||||
|
||||
case 'n':
|
||||
aConfig.mNat64 = true;
|
||||
break;
|
||||
|
||||
case '-':
|
||||
break;
|
||||
|
||||
default:
|
||||
ExitNow(error = OT_ERROR_INVALID_ARGS);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user