]> git.corax.cc Git - toolbox/commitdiff
include/conf: Add function to get available configuration entries
authorMatthias Kruk <m@m10k.eu>
Sat, 24 Jul 2021 06:27:29 +0000 (15:27 +0900)
committerMatthias Kruk <m@m10k.eu>
Sat, 24 Jul 2021 07:07:00 +0000 (16:07 +0900)
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.

include/conf.sh

index a5de6d0224d071a7df9cb96e272be0ab23d3fbcc..3cf7c9a645a59ea9f7755b20383be2677ff88946 100644 (file)
@@ -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
+}