Allow no args in settings command
All settings are printed in a tabulated format if no ID specified
This commit is contained in:
parent
e4668f0c04
commit
58055bf4b4
@ -173,7 +173,14 @@ static void add_callback(ItemIndex item, SettingsCallback callback)
|
|||||||
|
|
||||||
static int command_func(int argc, char **argv)
|
static int command_func(int argc, char **argv)
|
||||||
{
|
{
|
||||||
if (argc == 2) {
|
if (argc == 1) {
|
||||||
|
char buffer[SETTINGS_MAX_VALUE_SIZE];
|
||||||
|
for (unsigned i = 0; i < ITEM_COUNT; ++i) {
|
||||||
|
(void)get(i, buffer, SETTINGS_MAX_VALUE_SIZE);
|
||||||
|
printf("%-15s %s\n", state[i].id, buffer);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
} else if (argc == 2) {
|
||||||
for (unsigned i = 0; i < ITEM_COUNT; ++i) {
|
for (unsigned i = 0; i < ITEM_COUNT; ++i) {
|
||||||
if (strcmp(state[i].id, argv[1]) != 0)
|
if (strcmp(state[i].id, argv[1]) != 0)
|
||||||
continue;
|
continue;
|
||||||
@ -210,7 +217,7 @@ void settings_init()
|
|||||||
|
|
||||||
console_register(
|
console_register(
|
||||||
"settings", "Get or set a setting",
|
"settings", "Get or set a setting",
|
||||||
"settings <id> OR settings <id> <value>", command_func);
|
"settings [id] OR settings <id> <value>", command_func);
|
||||||
}
|
}
|
||||||
|
|
||||||
void settings_set_hostname(const char *hostname)
|
void settings_set_hostname(const char *hostname)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user