libs/uci: implement get_bool() to retrive uci variables as boolean value
This commit is contained in:
parent
c1eb7cf481
commit
b204c9ec8d
1 changed files with 19 additions and 9 deletions
|
@ -135,6 +135,16 @@ function Cursor.tset(self, config, section, values)
|
||||||
return stat
|
return stat
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Get a boolean option and return it's value as true or false.
|
||||||
|
-- @param config UCI config
|
||||||
|
-- @param section UCI section name
|
||||||
|
-- @param option UCI option
|
||||||
|
-- @return Boolean
|
||||||
|
function Cursor.get_bool(self, ...)
|
||||||
|
local val = self:get(...)
|
||||||
|
return ( val == "1" or val == "true" or val == "yes" or val == "on" )
|
||||||
|
end
|
||||||
|
|
||||||
--- Get an option or list and return values as table.
|
--- Get an option or list and return values as table.
|
||||||
-- @param config UCI config
|
-- @param config UCI config
|
||||||
-- @param section UCI section name
|
-- @param section UCI section name
|
||||||
|
|
Loading…
Reference in a new issue