1
0
Fork 0
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:
Dominic Clifton 2014-08-02 10:00:37 +01:00
parent 35a4aa60f9
commit 01643b8621

View file

@ -965,6 +965,15 @@ 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.
cliGet(cmdline);
}
}
static void cliGet(char *cmdline)
{
uint32_t i;
const clivalue_t *val;
for (i = 0; i < VALUE_COUNT; i++) { for (i = 0; i < VALUE_COUNT; i++) {
if (strstr(valueTable[i].name, cmdline)) { if (strstr(valueTable[i].name, cmdline)) {
val = &valueTable[i]; val = &valueTable[i];
@ -973,30 +982,9 @@ static void cliSet(char *cmdline)
printf("\r\n"); printf("\r\n");
} }
} }
}
}
static void cliGet(char *cmdline)
{
uint32_t i;
uint32_t len;
const clivalue_t *val;
len = strlen(cmdline);
// Find the matching variable
for (i = 0; i < VALUE_COUNT; i++) {
if ((strncasecmp(cmdline, valueTable[i].name, strlen(valueTable[i].name)) == 0) && (len == strlen(valueTable[i].name))) {
val = &valueTable[i];
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)