From: Jo-Philipp Wich Date: Sun, 17 Aug 2008 23:40:51 +0000 (+0000) Subject: * luci/libs: further fixes in uvl cli and library X-Git-Tag: 0.8.0~371 X-Git-Url: https://git.archive.openwrt.org/?p=project%2Fluci.git;a=commitdiff_plain;h=d0cbcfa45826b96d36522b8055ce0ba994a0879d * luci/libs: further fixes in uvl cli and library --- diff --git a/libs/uvl/luasrc/uvl.lua b/libs/uvl/luasrc/uvl.lua index b3701b17e..85962b402 100644 --- a/libs/uvl/luasrc/uvl.lua +++ b/libs/uvl/luasrc/uvl.lua @@ -110,6 +110,10 @@ function UVL.validate_config( self, config ) local co = self.uci.get_all( config ) local sc = { } + if not co then + return false, 'Unable to load configuration "' .. config .. '"' + end + local function _uci_foreach( type, func ) local ok, err for k, v in pairs(co) do @@ -179,6 +183,11 @@ function UVL.validate_section( self, config, section ) self.beenthere = { } local co = self.uci.get_all( config ) + + if not co then + return false, 'Unable to load configuration "' .. config .. '"' + end + if co[section] then return self:_validate_section( luci.uvl.section( self, co, co[section]['.type'], config, section @@ -208,6 +217,11 @@ function UVL.validate_option( self, config, section, option ) self.beenthere = { } 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 return self:_validate_option( luci.uvl.option( self, co, co[section]['.type'], config, section, option diff --git a/libs/uvl/root/usr/bin/uvl b/libs/uvl/root/usr/bin/uvl index 9fe34127f..3f179ee6a 100755 --- a/libs/uvl/root/usr/bin/uvl +++ b/libs/uvl/root/usr/bin/uvl @@ -103,17 +103,17 @@ else local uvl = luci.uvl.UVL( type(options.schemedir) == "string" and options.schemedir or nil ) - + 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 )