[FL-1239] CLI commands readable list #464

Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
gornekich
2021-05-18 12:30:04 +03:00
committed by GitHub
parent 734820c137
commit 5000424c42
3 changed files with 31 additions and 11 deletions

View File

@@ -5,7 +5,7 @@
Cli* cli_alloc() {
Cli* cli = furi_alloc(sizeof(Cli));
CliCommandDict_init(cli->commands);
CliCommandTree_init(cli->commands);
cli->mutex = osMutexNew(NULL);
furi_check(cli->mutex);
@@ -126,7 +126,7 @@ void cli_enter(Cli* cli) {
// Search for command
furi_check(osMutexAcquire(cli->mutex, osWaitForever) == osOK);
CliCommand* cli_command = CliCommandDict_get(cli->commands, command);
CliCommand* cli_command = CliCommandTree_get(cli->commands, command);
furi_check(osMutexRelease(cli->mutex) == osOK);
if(cli_command) {
cli_nl();
@@ -190,7 +190,7 @@ void cli_add_command(Cli* cli, const char* name, CliCallback callback, void* con
c.context = context;
furi_check(osMutexAcquire(cli->mutex, osWaitForever) == osOK);
CliCommandDict_set_at(cli->commands, name_str, c);
CliCommandTree_set_at(cli->commands, name_str, c);
furi_check(osMutexRelease(cli->mutex) == osOK);
string_clear(name_str);
@@ -207,7 +207,7 @@ void cli_delete_command(Cli* cli, const char* name) {
} while(name_replace != STRING_FAILURE);
furi_check(osMutexAcquire(cli->mutex, osWaitForever) == osOK);
CliCommandDict_erase(cli->commands, name_str);
CliCommandTree_erase(cli->commands, name_str);
furi_check(osMutexRelease(cli->mutex) == osOK);
string_clear(name_str);