summaryrefslogtreecommitdiff
path: root/Data/Libraries/Penlight/examples/testconfig.lua
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2021-10-30 11:32:16 +0800
committerchai <chaifix@163.com>2021-10-30 11:32:16 +0800
commit42ec7286b2d36a9ba22925f816a17cb1cc2aa5ce (patch)
tree24bc7009457a8d7500f264e89946dc20d069294f /Data/Libraries/Penlight/examples/testconfig.lua
parent164885fd98d48703bd771f802d79557b7db97431 (diff)
+ Penlight
Diffstat (limited to 'Data/Libraries/Penlight/examples/testconfig.lua')
-rw-r--r--Data/Libraries/Penlight/examples/testconfig.lua51
1 files changed, 51 insertions, 0 deletions
diff --git a/Data/Libraries/Penlight/examples/testconfig.lua b/Data/Libraries/Penlight/examples/testconfig.lua
new file mode 100644
index 0000000..4712747
--- /dev/null
+++ b/Data/Libraries/Penlight/examples/testconfig.lua
@@ -0,0 +1,51 @@
+local stringio = require 'pl.stringio'
+local config = require 'pl.config'
+
+local function dump(t,indent)
+ if type(t) == 'table' then
+ io.write(indent,'{\n')
+ local newindent = indent..' '
+ for k,v in pairs(t) do
+ io.write(newindent,k,'=')
+ dump(v,indent)
+ io.write('\n')
+ end
+ io.write(newindent,'},\n')
+ else
+ io.write(indent,t,'(',type(t),')')
+ end
+end
+
+
+local function testconfig(test)
+ local f = stringio.open(test)
+ local c = config.read(f)
+ f:close()
+ dump(c,' ')
+ print '-----'
+end
+
+testconfig [[
+ ; comment 2 (an ini file)
+[section!]
+bonzo.dog=20,30
+config_parm=here we go again
+depth = 2
+[another]
+felix="cat"
+]]
+
+testconfig [[
+# this is a more Unix-y config file
+fred = 1
+alice = 2
+home = /bonzo/dog/etc
+]]
+
+testconfig [[
+# this is just a set of comma-separated values
+1000,444,222
+44,555,224
+]]
+
+