simplify and rename the init function
This commit is contained in:
33
eatit.lua
33
eatit.lua
@ -37,6 +37,22 @@ local function logwrite(string)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function openlog()
|
||||||
|
if opts.logging.log then -- log if asked to
|
||||||
|
-- get our logfile's full path
|
||||||
|
fn = mp.command_native({'expand-path', opts.logging.logfile})
|
||||||
|
|
||||||
|
f = io.open(fn, 'a') -- open file buffer
|
||||||
|
io.output(f) -- set it as default
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function closelog()
|
||||||
|
if opts.logging.log then
|
||||||
|
io.close(f)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- get the requested git repos
|
-- get the requested git repos
|
||||||
local function clonegit(i)
|
local function clonegit(i)
|
||||||
logwrite('downloading ' .. plugins[i][1])
|
logwrite('downloading ' .. plugins[i][1])
|
||||||
@ -127,15 +143,8 @@ local function startinstall()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function init()
|
local function initupdate()
|
||||||
if opts.logging.log then -- log if asked to
|
openlog()
|
||||||
-- get our logfile's full path
|
|
||||||
local fn = mp.command_native({'expand-path', opts.logging.logfile})
|
|
||||||
|
|
||||||
os.remove(fn) -- remove logfile so that we start fresh
|
|
||||||
f = io.open(fn, 'a') -- open file buffer
|
|
||||||
io.output(f) -- set it as default
|
|
||||||
end
|
|
||||||
|
|
||||||
logwrite('# of plugins defined in table: ' .. tablelength(plugins))
|
logwrite('# of plugins defined in table: ' .. tablelength(plugins))
|
||||||
os.execute('mkdir -p ' .. opts.dl.dir) -- make download dir
|
os.execute('mkdir -p ' .. opts.dl.dir) -- make download dir
|
||||||
@ -146,9 +155,9 @@ local function init()
|
|||||||
logwrite('powerwashing the tmp dir (' .. opts.dl.dir .. ')')
|
logwrite('powerwashing the tmp dir (' .. opts.dl.dir .. ')')
|
||||||
os.execute('rm -rf ' .. opts.dl.dir)
|
os.execute('rm -rf ' .. opts.dl.dir)
|
||||||
end
|
end
|
||||||
if opts.logging.log then
|
|
||||||
io.close(f)
|
closelog()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
mp.add_key_binding('U', 'UpdatePlugins', init)
|
mp.add_key_binding('U', 'UpdatePlugins', initupdate)
|
||||||
|
Reference in New Issue
Block a user