telemetry: make help command more helpful

The /help telemetry command prints out the help text for the given
command passed in as parameter. However, entering /help without any
parameters does not give any useful information as to the fact that you
need to pass in a command to get help on. Update the command so it
prints its own help text when called without any parameters.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
Acked-by: Ciara Power <ciara.power@intel.com>
Acked-by: Morten Brørup <mb@smartsharesystems.com>
Acked-by: Chengwen Feng <fengchengwen@huawei.com>
This commit is contained in:
Bruce Richardson 2022-09-09 10:35:23 +01:00 committed by David Marchand
parent 0f3d92f373
commit 2607c9cbeb

View File

@ -142,15 +142,17 @@ command_help(const char *cmd __rte_unused, const char *params,
struct rte_tel_data *d)
{
int i;
/* if no parameters return our own help text */
const char *to_lookup = (params == NULL ? cmd : params);
if (!params)
return -1;
rte_tel_data_start_dict(d);
rte_spinlock_lock(&callback_sl);
for (i = 0; i < num_callbacks; i++)
if (strcmp(params, callbacks[i].cmd) == 0) {
rte_tel_data_add_dict_string(d, params,
callbacks[i].help);
if (strcmp(to_lookup, callbacks[i].cmd) == 0) {
if (params == NULL)
rte_tel_data_string(d, callbacks[i].help);
else
rte_tel_data_add_dict_string(d, params, callbacks[i].help);
break;
}
rte_spinlock_unlock(&callback_sl);