Skip to content
Snippets Groups Projects
Unverified Commit 0dd03597 authored by Matthias Schiffer's avatar Matthias Schiffer
Browse files

gluon-config-mode-core: allow returning functions from wizard modules

Allow returning functions in addition to the names of UCI packages to
commit. Functions are run after all packages have been committed.
parent 345a5de8
No related branches found
No related tags found
No related merge requests found
......@@ -28,11 +28,18 @@ local s = f:section(Section)
s.template = "gluon/config-mode/welcome"
local commit = {'gluon-setup-mode'}
local run = {}
for _, w in ipairs(wizard) do
for _, c in ipairs(w(f, uci) or {}) do
if not util.contains(commit, c) then
table.insert(commit, c)
if type(c) == 'string' then
if not util.contains(commit, c) then
table.insert(commit, c)
end
elseif type(c) == 'function' then
table.insert(run, c)
else
error('invalid wizard module return')
end
end
end
......@@ -45,6 +52,9 @@ function f:write()
for _, c in ipairs(commit) do
uci:commit(c)
end
for _, r in ipairs(run) do
r()
end
f.template = "gluon/config-mode/reboot"
f.hidenav = true
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment