mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-15 04:15:44 +03:00
Re-use existing code to show all matching cli commands for 'get' instead of exact match.
e.g. 'get deadband' will show all varialbles with the word 'deadband' in it. exact match only required when setting variables.
This commit is contained in:
parent
35a4aa60f9
commit
01643b8621
1 changed files with 12 additions and 24 deletions
|
@ -965,38 +965,26 @@ static void cliSet(char *cmdline)
|
||||||
cliPrint("ERR: Unknown variable name\r\n");
|
cliPrint("ERR: Unknown variable name\r\n");
|
||||||
} else {
|
} else {
|
||||||
// no equals, check for matching variables.
|
// no equals, check for matching variables.
|
||||||
for (i = 0; i < VALUE_COUNT; i++) {
|
cliGet(cmdline);
|
||||||
if (strstr(valueTable[i].name, cmdline)) {
|
|
||||||
val = &valueTable[i];
|
|
||||||
printf("%s = ", valueTable[i].name);
|
|
||||||
cliPrintVar(val, 0);
|
|
||||||
printf("\r\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cliGet(char *cmdline)
|
static void cliGet(char *cmdline)
|
||||||
{
|
{
|
||||||
uint32_t i;
|
uint32_t i;
|
||||||
uint32_t len;
|
|
||||||
const clivalue_t *val;
|
const clivalue_t *val;
|
||||||
|
|
||||||
len = strlen(cmdline);
|
for (i = 0; i < VALUE_COUNT; i++) {
|
||||||
|
if (strstr(valueTable[i].name, cmdline)) {
|
||||||
// Find the matching variable
|
val = &valueTable[i];
|
||||||
for (i = 0; i < VALUE_COUNT; i++) {
|
printf("%s = ", valueTable[i].name);
|
||||||
if ((strncasecmp(cmdline, valueTable[i].name, strlen(valueTable[i].name)) == 0) && (len == strlen(valueTable[i].name))) {
|
cliPrintVar(val, 0);
|
||||||
val = &valueTable[i];
|
printf("\r\n");
|
||||||
printf("%s = ", valueTable[i].name);
|
}
|
||||||
cliPrintVar(val, 0);
|
}
|
||||||
printf("\r\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// If we get down here, then the variable was not found
|
// If we get down here, then the variable was not found
|
||||||
printf("Variable '%s' not found.\r\n ", cmdline);
|
cliPrint("ERR: Unknown variable name\r\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cliStatus(char *cmdline)
|
static void cliStatus(char *cmdline)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue