lua-simple-uci: delete option when using Cursor:set() with nil value

Setting the section type when using set() with only two arguments is a very
confusing behaviour. section() can be used without a value table for the
same result.

Deleting the option instead will make set() and get() symmetric and will
allow to simplify some code that needed to check for nil to call set() or
delete() before.
This commit is contained in:
Matthias Schiffer 2017-08-08 03:52:14 +02:00
parent c9fa162ebb
commit 8b65619f59
No known key found for this signature in database
GPG Key ID: 16EF3F64CB201D9C
1 changed files with 2 additions and 2 deletions

View File

@ -31,7 +31,7 @@ function Cursor:set(config, section, option, value)
return uciset(self, config, section, option, value) return uciset(self, config, section, option, value)
else else
return uciset(self, config, section, option) return self:delete(config, section, option)
end end
end end
@ -68,7 +68,7 @@ end
function Cursor:section(config, type, name, values) function Cursor:section(config, type, name, values)
local stat = true local stat = true
if name then if name then
stat = self:set(config, name, type) stat = uciset(self, config, name, type)
else else
name = self:add(config, type) name = self:add(config, type)
stat = name and true stat = name and true