From f4934be45ed47c7858c3bedc2d16794e011eb403 Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Tue, 9 May 2023 17:30:56 -0700 Subject: setup: label anon nested settings as subscripts It'll be perfectly normal to turn bare-value settings int nested instances. In such scenarios we don't have a static spec-supplied key for the label, so let's just generate a label like a C-style array subscript for such instances. --- src/setup.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/setup.c b/src/setup.c index 5d99178..aeea763 100644 --- a/src/setup.c +++ b/src/setup.c @@ -37,7 +37,18 @@ int setup_interactively(til_settings_t *settings, int (*setup_func)(const til_se } if (desc->spec.as_nested_settings && !setting->value_as_nested_settings) { - setting->value_as_nested_settings = til_settings_new(setting->key, setting->value); + char *label = NULL; + + if (!desc->spec.key) { + /* generate a positional label for bare-value specs */ + r = til_settings_label_setting(desc->container, setting, &label); + if (r < 0) + return r; + } + + setting->value_as_nested_settings = til_settings_new(desc->spec.key ? : label, setting->value); + free(label); + if (!setting->value_as_nested_settings) { *res_failed_desc = desc; -- cgit v1.2.3