add comments, change formatting on powerwash logging, ...

only remove log if logging is enabled
This commit is contained in:
2023-07-16 20:22:13 -04:00
parent a566b63fa5
commit 2162b9cd2e
2 changed files with 17 additions and 8 deletions

View File

@ -18,10 +18,11 @@ GNU General Public License for more details.
-- after being called with dofile() -- after being called with dofile()
plugins = { -- the plugins you want to load plugins = { -- the plugins you want to load
{ 'https://git.squi.bid/eat-it', { 'https://git.squi.bid/eat-it', -- required, specifies the git repo
file = 'eatit.lua', file = 'eatit.lua', -- required, specifies the desired file
dir = 'scripts', dir = 'scripts', -- optional, sets the dest dir
cfg = function() branch = 'master', -- optional, sets the desired branch
cfg = function() -- optional, runs code on mpv startup
print('this is an example') print('this is an example')
end end
}, },

View File

@ -97,13 +97,17 @@ end
-- start install -- start install
local function startinstall() local function startinstall()
-- let the user know that we are starting install
logwrite('Starting Download...') logwrite('Starting Download...')
mp.osd_message('Downloading plugins!') mp.osd_message('Downloading plugins!')
-- start iterating through plugins
for i = 1, tablelength(plugins) do for i = 1, tablelength(plugins) do
-- check if the user has defined a file for the current plugin -- check if the user has defined a file for the current plugin
if not plugins[i]['file'] then if not plugins[i]['file'] then
logwrite('WARNING! Git repo "' .. plugins[i][1] .. logwrite('WARNING! Git repo "' .. plugins[i][1] ..
'" doesn\'t have a specified file. Skipping download') '" doesn\'t have a specified file. Skipping download')
-- FIXME: this results in the last plugin being downloaded & copied twice -- FIXME: this results in the last plugin being downloaded & copied twice
i = i + 1 -- if not we go to the next plugin i = i + 1 -- if not we go to the next plugin
end end
@ -153,7 +157,7 @@ local function initupdate()
-- closing/removing everything -- closing/removing everything
if opts.dl.powerwash == true then if opts.dl.powerwash == true then
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
@ -161,6 +165,8 @@ local function initupdate()
end end
-- run any user defined configs at startup -- run any user defined configs at startup
-- NOTE: This is kinda useless and might be removed if there is no way to make
-- it run in the desired plugin's thread
local function runopts() local function runopts()
openlog() openlog()
for i = 1, tablelength(plugins) do for i = 1, tablelength(plugins) do
@ -173,9 +179,11 @@ local function runopts()
end end
-- remove logfile on startup -- remove logfile on startup
openlog() if opts.logging.log then
os.remove(fn) openlog()
closelog() os.remove(fn)
closelog()
end
runopts() runopts()
mp.add_key_binding(opts.bind, 'UpdatePlugins', initupdate) mp.add_key_binding(opts.bind, 'UpdatePlugins', initupdate)