Allow no args in settings command

All settings are printed in a tabulated format if no ID specified
This commit is contained in:
Camden Dixie O'Brien 2023-05-19 16:15:55 +01:00
parent e4668f0c04
commit 58055bf4b4

View File

@ -173,7 +173,14 @@ static void add_callback(ItemIndex item, SettingsCallback callback)
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) {
if (strcmp(state[i].id, argv[1]) != 0)
continue;
@ -210,7 +217,7 @@ void settings_init()
console_register(
"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)