diff options
author | Squibid <me@zacharyscheiman.com> | 2023-07-03 15:54:57 -0400 |
---|---|---|
committer | Squibid <me@zacharyscheiman.com> | 2023-07-03 15:54:57 -0400 |
commit | 1d5e908b77f4820b6d14a4faef285bd3b59bb62d (patch) | |
tree | 25843f93a0c8092183f9ce40abd6d66853eda400 | |
parent | 1f407569f19677564be75ef21467ced344d2154e (diff) | |
download | eat-it-1d5e908b77f4820b6d14a4faef285bd3b59bb62d.tar.gz eat-it-1d5e908b77f4820b6d14a4faef285bd3b59bb62d.tar.bz2 eat-it-1d5e908b77f4820b6d14a4faef285bd3b59bb62d.zip |
simplify and rename the init function
Diffstat (limited to '')
-rw-r--r-- | eatit.lua | 33 |
1 files changed, 21 insertions, 12 deletions
@@ -37,6 +37,22 @@ local function logwrite(string) 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 local function clonegit(i) logwrite('downloading ' .. plugins[i][1]) @@ -127,15 +143,8 @@ local function startinstall() end end -local function init() - if opts.logging.log then -- log if asked to - -- 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 +local function initupdate() + openlog() logwrite('# of plugins defined in table: ' .. tablelength(plugins)) 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 .. ')') os.execute('rm -rf ' .. opts.dl.dir) end - if opts.logging.log then - io.close(f) + + closelog() end end -mp.add_key_binding('U', 'UpdatePlugins', init) +mp.add_key_binding('U', 'UpdatePlugins', initupdate) |