summaryrefslogtreecommitdiffhomepage
path: root/libs/uvl/root
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2008-09-04 00:56:13 +0000
committerJo-Philipp Wich <jow@openwrt.org>2008-09-04 00:56:13 +0000
commit19e22598fd5b43a4e3e23e5e0d5f994281024035 (patch)
treec1aa83ca892d1380d2273f29bda950e865e804ef /libs/uvl/root
parent34ab619ee3dd9fd04a4198288540e3a7a19aadf6 (diff)
* luci/libs/uvl:
- implement aliasing in luci.uvl.read_scheme() - fixed wrong enum definition in reference scheme - fixed boolean() datatype validator to actually accept "true" and "false" literals - extend uvl cli to validate schemes against the reference scheme (incomplete)
Diffstat (limited to 'libs/uvl/root')
-rw-r--r--libs/uvl/root/lib/uci/schema/meta/schema4
-rwxr-xr-xlibs/uvl/root/usr/bin/uvl37
2 files changed, 31 insertions, 10 deletions
diff --git a/libs/uvl/root/lib/uci/schema/meta/schema b/libs/uvl/root/lib/uci/schema/meta/schema
index 1d673d350..dd373f8ae 100644
--- a/libs/uvl/root/lib/uci/schema/meta/schema
+++ b/libs/uvl/root/lib/uci/schema/meta/schema
@@ -305,8 +305,8 @@ config section
# Enum value (schema.@enum.value)
config variable
- option name 'name'
- option title 'Name of the defined variable'
+ option name 'value'
+ option title 'Value of the defined enum value'
option section 'schema.enum'
option type 'variable'
option datatype 'string'
diff --git a/libs/uvl/root/usr/bin/uvl b/libs/uvl/root/usr/bin/uvl
index 0fe7a13a7..83ed73941 100755
--- a/libs/uvl/root/usr/bin/uvl
+++ b/libs/uvl/root/usr/bin/uvl
@@ -149,9 +149,9 @@ $Id$
Usage:
uvl --help
- uvl [--silent] [--schemedir=DIR]
- [--no-strict-sections] [--no-strict-options] [--no-strict-validators]
- [--no-strict-lists] {verify|genspec} config[.section[.option]]
+ uvl [--silent] [--schemedir=DIR] [--configdir=DIR] [--no-strict-sections] \
+ [--no-strict-options] [--no-strict-validators] [--no-strict-lists] \
+ {verify|verify-scheme|genspec} config[.section[.option]]
Options:
--help
@@ -163,6 +163,9 @@ Options:
--schemedir=DIR
Use DIR as scheme directory.
+ --configdir=DIR
+ Use DIR as config directory.
+
--no-strict-sections
Don't treat sections found in config but not in scheme as error.
@@ -179,11 +182,14 @@ Actions:
verify
Validate given configuration, section or option.
+ verify-scheme
+ Validate given scheme against the reference meta scheme.
+
genspec
Generate a scheme skeleton from given configuration.
]=])
os.exit(255)
-elseif arguments[1] == "verify" then
+elseif arguments[1] == "verify" or arguments[1] == "verify-scheme" then
luci.uvl.STRICT_UNKNOWN_SECTIONS =
( not options['no-strict-sections'] and true or false )
luci.uvl.STRICT_UNKNOWN_OPTIONS =
@@ -194,18 +200,33 @@ elseif arguments[1] == "verify" then
( not options['no-strict-lists'] and true or false )
local uvl = luci.uvl.UVL(
- type(options.schemedir) == "string" and options.schemedir or nil
+ type(options.schemedir) == "string" and options.schemedir
)
local cso = luci.util.split( arguments[2], "." )
- local ok, err = uvl:validate( unpack(cso) )
+ local ok, err
+
+ if arguments[1] == "verify-scheme" then
+ uvl:read_scheme( 'schema', cso[1] )
+
+ local uci = uvl.uci.cursor(
+ type(options.configdir) == "string"
+ and options.configdir or uvl.schemedir .. '/default'
+ )
+
+ ok, err = uvl:validate_config( cso[1], uci:get_all(cso[1]) )
+ if err then err.code = luci.uvl.errors.ERR_SCHEME end
+ else
+ ok, err = uvl:validate( unpack(cso) )
+ end
if ok then
if not options.silent then
print( string.format(
'%s "%s" validates fine!',
- ( #cso == 1 and "Config" or
- ( #cso == 2 and "Section" or "Option" ) ),
+ ( arguments[1] == "verify-scheme" and "Scheme" or
+ ( #cso == 1 and "Config" or
+ ( #cso == 2 and "Section" or "Option" ) ) ),
table.concat(cso, ".")
) )
end