* libs/luci: implement get_list() and set_list() wrappers in luci.model.uci
This commit is contained in:
parent
c82392c6f2
commit
6802546621
1 changed files with 36 additions and 6 deletions
|
@ -135,6 +135,36 @@ function tset(config, section, values)
|
||||||
return stat
|
return stat
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Get an option or list and return values as table.
|
||||||
|
-- @param config UCI config
|
||||||
|
-- @param section UCI section name
|
||||||
|
-- @param option UCI option
|
||||||
|
-- @return UCI value
|
||||||
|
function get_list(config, section, option)
|
||||||
|
if config and section and option then
|
||||||
|
local val = get(config, section, option)
|
||||||
|
return ( type(val) == "table" and val or { val } )
|
||||||
|
end
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Set given values as list.
|
||||||
|
-- Warning: This function is unsave! You should use save_config or save_state if possible.
|
||||||
|
-- @param config UCI config
|
||||||
|
-- @param section UCI section name
|
||||||
|
-- @param option UCI option
|
||||||
|
-- @param value UCI value
|
||||||
|
-- @return Boolean whether operation succeeded
|
||||||
|
function set_list(config, section, option, value)
|
||||||
|
if config and section and option then
|
||||||
|
return set(
|
||||||
|
config, section, option,
|
||||||
|
( type(value) == "table" and value or { value } )
|
||||||
|
)
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Add an anonymous section.
|
--- Add an anonymous section.
|
||||||
-- @class function
|
-- @class function
|
||||||
|
|
Loading…
Reference in a new issue