diff options
-rw-r--r-- | lib/format.lua | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/format.lua b/lib/format.lua index f012c3b..e19899f 100644 --- a/lib/format.lua +++ b/lib/format.lua @@ -82,6 +82,18 @@ function parse_linesandwords ( input ) return lines end +-- returns a table with label value pairs + +function parse_configfile( input ) + local config = {} + local lines = parse_linesandwords(input) + + for i,linetable in ipairs(lines) do + config[linetable[1]] = table.concat(linetable, " ", 2) or "" + end + return config +end + -- search and replace through a table -- string is easy string.gsub(string, find, replace) |