+#!/usr/bin/lua
--[[
UCI Validation Layer - Command Line Utility
http://www.apache.org/licenses/LICENSE-2.0
-$Id: uvl.lua 2873 2008-08-17 21:43:56Z jow $
+$Id$
]]--
if #arguments == 0 or options.help then
print([=[
+
uvl - UCI Validation Layer
-$Id: uvl.lua 2873 2008-08-17 21:43:56Z jow $
+$Id$
(c) 2008 Jo-Philipp Wich, Steven Barth
Usage:
uvl --help
- uvl [--silent] [--no-strict-sections] [--no-strict-options]
- [--no-strict-validators] config[.section[.option]]
+ uvl [--silent] [--schemedir=DIR]
+ [--no-strict-sections] [--no-strict-options] [--no-strict-validators]
+ [--no-strict-lists] config[.section[.option]]
Options:
--help
--silent
Don't produce any output.
+ --schemedir=DIR
+ Use DIR as scheme directory.
+
--no-strict-sections
Don't treat sections found in config but not in scheme as error.
Don't treat options found in config but not in scheme as error.
--no-strict-validators
- Don't invalidate config if an external validators fails.
+ Don't invalidate config if an external validator fails.
+ --no-strict-lists
+ Don't invalidate lists that are stored options.
]=])
os.exit(255)
else
( options['no-strict-options'] and false or true )
luci.uvl.STRICT_EXTERNAL_VALIDATORS =
( options['no-strict-validators'] and false or true )
+ luci.uvl.STRICT_LIST_TYPE =
+ ( options['no-strict-lists'] and false or true )
+
+ local uvl = luci.uvl.UVL(
+ type(options.schemedir) == "string" and options.schemedir or nil
+ )
- local uvl = luci.uvl.UVL( options['schemedir'] )
local cso = luci.util.split( arguments[1], "." )
local ok, err = uvl:validate( unpack(cso) )
if ok then
if not options.silent then
print( string.format(
- '%s "%s.%s.%s" validates fine!',
+ '%s "%s" validates fine!',
( #cso == 1 and "Config" or
( #cso == 2 and "Section" or "Option" ) ),
- cso[1], cso[2], cso[3]
+ table.concat(cso, ".")
) )
end
os.exit( 0 )