From: Matthias Kruk Date: Sat, 24 Jul 2021 06:27:29 +0000 (+0900) Subject: include/conf: Add function to get available configuration entries X-Git-Url: https://git.corax.cc/?a=commitdiff_plain;h=480a2210694540b830b03d5675cfdfb23e59c178;p=toolbox include/conf: Add function to get available configuration entries The conf module currently does not provide a means to figure out what configuration entries are available. This commit adds a method that allows the caller to figure out what configuration settings are available in a given configuration domain. --- diff --git a/include/conf.sh b/include/conf.sh index a5de6d0..3cf7c9a 100644 --- a/include/conf.sh +++ b/include/conf.sh @@ -105,3 +105,21 @@ conf_get_domains() { return 0 } + +conf_get_names() { + local config="$1" + + local confpath + + if [[ -z "$config" ]]; then + config="default" + fi + + confpath="$__conf_root/$config.conf" + + if ! grep -oP "^\\K[^=]+" < "$confpath"; then + return 1 + fi + + return 0 +}