Clean way to run-time disable "help" command in FreeRTOS+CLI?

I’m using FreeRTOS+CLI V1.0.4 and would like to disable/enable the “help” command based on a run-time setting in my code. I can easily do this by having prvHelpCommand() check the status of the setting, but I don’t like this approach as it would require modifying the nicely compartmentalized CLI code to be aware of very application specific things.

Is there a clean way to do this without compromising the CLI source isolation?

Having the help command check the status is likely your best option as the library does not provide a function for unregistering a command.

Alternatively, since your code owns the CLI_Command_Definition_t for the command, when the run-time setting is changed, you could modify the help command struct’s pxCommandInterpreter field to a handler that performs the enabled/disabled behavior. Though in this case you would want to be careful if this is accessed from multiple tasks.

Thanks, I’ll look into your suggestion about modifying the pxCommandInterpreter field.

My current solution was to add a static UBaseType_t (*puxHelpEnabled)(void) function pointer to FreeRTOS_CLI.c and a function to register it. Then I register my app’s function that checks the setting and have prvHelpCommand check that. It’s not the cleanest, but it does work and maintains the separation of the CLI code from my app.