mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-09 12:35:28 +00:00
change(console): print sorted help
console commands may be registered in random order in application, for example each module registers its own commands. the output of help is displayed to human, best to have consistent sorted output so that the implementation ordering will not affect the output and allow the user to see a list in some logic order. Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
This commit is contained in:
@@ -130,14 +130,17 @@ esp_err_t esp_console_cmd_register(const esp_console_cmd_t *cmd)
|
||||
}
|
||||
item->argtable = cmd->argtable;
|
||||
item->func = cmd->func;
|
||||
cmd_item_t *last = SLIST_FIRST(&s_cmd_list);
|
||||
cmd_item_t *last = NULL;
|
||||
cmd_item_t *it;
|
||||
SLIST_FOREACH(it, &s_cmd_list, next) {
|
||||
if (strcmp(it->command, item->command) > 0) {
|
||||
break;
|
||||
}
|
||||
last = it;
|
||||
}
|
||||
if (last == NULL) {
|
||||
SLIST_INSERT_HEAD(&s_cmd_list, item, next);
|
||||
} else {
|
||||
cmd_item_t *it;
|
||||
while ((it = SLIST_NEXT(last, next)) != NULL) {
|
||||
last = it;
|
||||
}
|
||||
SLIST_INSERT_AFTER(last, item, next);
|
||||
}
|
||||
return ESP_OK;
|
||||
|
Reference in New Issue
Block a user