summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2023-05-09 17:30:56 -0700
committerVito Caputo <vcaputo@pengaru.com>2023-05-11 15:19:25 -0700
commitf4934be45ed47c7858c3bedc2d16794e011eb403 (patch)
tree68f343b45813c1c71443d1218dda98799663af53 /src
parent80905545cdd85536191486b8fe2095686d197f58 (diff)
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.
Diffstat (limited to 'src')
-rw-r--r--src/setup.c13
1 files changed, 12 insertions, 1 deletions
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;
© All Rights Reserved