3 LuCI - Lua Configuration Interface
5 Copyright 2008 Steven Barth <steven@midlink.org>
6 Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
8 Licensed under the Apache License, Version 2.0 (the "License");
9 you may not use this file except in compliance with the License.
10 You may obtain a copy of the License at
12 http://www.apache.org/licenses/LICENSE-2.0
17 local uvl = require "luci.uvl"
18 local util = require "luci.util"
21 util.perror("Usage %s scheme_name" % arg[0])
27 local scheme, error = uvl.UVL():get_scheme(arg[1])
30 print( error:string() )
35 print('cbimap = Map(%q, %q, %q)\n'
36 % { scheme.name, scheme.title or scheme.name, scheme.description or "" } )
39 for sn, sv in util.kspairs(scheme.sections) do
40 print('%s = cbimap:section(TypedSection, %q, %q, %q)'
41 % { sn, sn, sv.title or "", sv.description or "" } )
43 if not sv.named then print('%s.anonymous = true' % sn) end
44 if not sv.unique then print('%s.addremove = true' % sn) end
45 if sv.dynamic then print('%s.dynamic = true' % sn) end
48 for _, dep in ipairs(sv.depends) do
49 print('%s:depends(%s)' % { sn, util.serialize_data(dep) } )
55 for vn, vv in util.kspairs(scheme.variables[sn]) do
56 if not vv.type or vv.type == "variable" then
57 print('%s = %s:option(%s, %q, %q, %q)'
58 % { vn, sn, vv.datatype == "boolean" and "Flag" or "Value",
59 vn, vv.title or "", vv.description or "" } )
60 elseif vv.type == "enum" then
61 print('%s = %s:option(%s, %q, %q, %q)'
62 % { vn, sn, vv.multival and "MultiValue" or "ListValue",
63 vn, vv.title or "", vv.description or "" } )
65 for _, val in ipairs(vv.valuelist or {}) do
66 print('%s:value(%q, %q)'
67 % { vn, val.value, val.title or val.value } )
69 elseif vv.type == "list" or vv.type == "lazylist" then
70 print('%s = %s:option(DynamicList, %q, %q, %q)'
71 % { vn, sn, vn, vv.title or "", vv.description or "" } )
73 print('-- option: type(%s) ?' % { vv.type or "" } )
76 if vv.default then print('%s.default = %q' % { vn, vv.default } ) end
77 if vv.required then print('%s.optional = false' % vn ) end
78 if not vv.required then print('%s.rmempty = true' % vn ) end
80 for _, dep in ipairs(vv.depends or {}) do
81 print('%s:depends(%s)' % { vn, util.serialize_data(dep) } )
87 print('\nreturn cbimap')