[cli] store cli user commands in container and support list prepend (#8977)

Calls to otCliSetUserCommand overwrite the pointer user command list
pointer each time it is invoked, which results in successive calls to
otCliSetUserCommand replacing the previously registered command list
instead of appending to it. This is particularly relevant for the
posix platform in which the main function registers a set of posix
specific commands without any way to extend the set.

This commit replaces the command list pointer with a container of
command lists associated with a registered context in order to support
prepending the active list of user commands up to a configurable value
which defaults to 1 to maintain current behavior.
This commit is contained in:
Nick Bertoldi
2023-04-26 09:07:30 -07:00
committed by GitHub
parent 5e15b93ff2
commit 5657335de4
7 changed files with 69 additions and 30 deletions
+1 -1
View File
@@ -126,7 +126,7 @@ pseudo_reset:
otAppCliInit(instance);
#if OPENTHREAD_POSIX && !defined(FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION)
otCliSetUserCommands(kCommands, OT_ARRAY_LENGTH(kCommands), instance);
IgnoreError(otCliSetUserCommands(kCommands, OT_ARRAY_LENGTH(kCommands), instance));
#endif
while (!otSysPseudoResetWasRequested())