* luci/libs: further fixes in uvl cli and library
This commit is contained in:
parent
6d5efc7925
commit
d0cbcfa458
2 changed files with 17 additions and 3 deletions
|
@ -110,6 +110,10 @@ function UVL.validate_config( self, config )
|
||||||
local co = self.uci.get_all( config )
|
local co = self.uci.get_all( config )
|
||||||
local sc = { }
|
local sc = { }
|
||||||
|
|
||||||
|
if not co then
|
||||||
|
return false, 'Unable to load configuration "' .. config .. '"'
|
||||||
|
end
|
||||||
|
|
||||||
local function _uci_foreach( type, func )
|
local function _uci_foreach( type, func )
|
||||||
local ok, err
|
local ok, err
|
||||||
for k, v in pairs(co) do
|
for k, v in pairs(co) do
|
||||||
|
@ -179,6 +183,11 @@ function UVL.validate_section( self, config, section )
|
||||||
self.beenthere = { }
|
self.beenthere = { }
|
||||||
|
|
||||||
local co = self.uci.get_all( config )
|
local co = self.uci.get_all( config )
|
||||||
|
|
||||||
|
if not co then
|
||||||
|
return false, 'Unable to load configuration "' .. config .. '"'
|
||||||
|
end
|
||||||
|
|
||||||
if co[section] then
|
if co[section] then
|
||||||
return self:_validate_section( luci.uvl.section(
|
return self:_validate_section( luci.uvl.section(
|
||||||
self, co, co[section]['.type'], config, section
|
self, co, co[section]['.type'], config, section
|
||||||
|
@ -208,6 +217,11 @@ function UVL.validate_option( self, config, section, option )
|
||||||
self.beenthere = { }
|
self.beenthere = { }
|
||||||
|
|
||||||
local co = self.uci.get_all( config )
|
local co = self.uci.get_all( config )
|
||||||
|
|
||||||
|
if not co then
|
||||||
|
return false, 'Unable to load configuration "' .. config .. '"'
|
||||||
|
end
|
||||||
|
|
||||||
if co[section] and co[section][option] then
|
if co[section] and co[section][option] then
|
||||||
return self:_validate_option( luci.uvl.option(
|
return self:_validate_option( luci.uvl.option(
|
||||||
self, co, co[section]['.type'], config, section, option
|
self, co, co[section]['.type'], config, section, option
|
||||||
|
|
|
@ -103,17 +103,17 @@ else
|
||||||
local uvl = luci.uvl.UVL(
|
local uvl = luci.uvl.UVL(
|
||||||
type(options.schemedir) == "string" and options.schemedir or nil
|
type(options.schemedir) == "string" and options.schemedir or nil
|
||||||
)
|
)
|
||||||
|
|
||||||
local cso = luci.util.split( arguments[1], "." )
|
local cso = luci.util.split( arguments[1], "." )
|
||||||
local ok, err = uvl:validate( unpack(cso) )
|
local ok, err = uvl:validate( unpack(cso) )
|
||||||
|
|
||||||
if ok then
|
if ok then
|
||||||
if not options.silent then
|
if not options.silent then
|
||||||
print( string.format(
|
print( string.format(
|
||||||
'%s "%s.%s.%s" validates fine!',
|
'%s "%s" validates fine!',
|
||||||
( #cso == 1 and "Config" or
|
( #cso == 1 and "Config" or
|
||||||
( #cso == 2 and "Section" or "Option" ) ),
|
( #cso == 2 and "Section" or "Option" ) ),
|
||||||
cso[1], cso[2], cso[3]
|
table.concat(cso, ".")
|
||||||
) )
|
) )
|
||||||
end
|
end
|
||||||
os.exit( 0 )
|
os.exit( 0 )
|
||||||
|
|
Loading…
Reference in a new issue