From 2162b9cd2e0d307fed376f909c75db6c0afac217 Mon Sep 17 00:00:00 2001 From: Squibid Date: Sun, 16 Jul 2023 20:22:13 -0400 Subject: add comments, change formatting on powerwash logging, ... only remove log if logging is enabled --- eatit-cfg.lua | 9 +++++---- eatit.lua | 16 ++++++++++++---- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/eatit-cfg.lua b/eatit-cfg.lua index 7d3eb76..dcdc95e 100644 --- a/eatit-cfg.lua +++ b/eatit-cfg.lua @@ -18,10 +18,11 @@ GNU General Public License for more details. -- after being called with dofile() plugins = { -- the plugins you want to load - { 'https://git.squi.bid/eat-it', - file = 'eatit.lua', - dir = 'scripts', - cfg = function() + { 'https://git.squi.bid/eat-it', -- required, specifies the git repo + file = 'eatit.lua', -- required, specifies the desired file + dir = 'scripts', -- optional, sets the dest dir + branch = 'master', -- optional, sets the desired branch + cfg = function() -- optional, runs code on mpv startup print('this is an example') end }, diff --git a/eatit.lua b/eatit.lua index 6bd70fe..353d72c 100644 --- a/eatit.lua +++ b/eatit.lua @@ -97,13 +97,17 @@ end -- start install local function startinstall() + -- let the user know that we are starting install logwrite('Starting Download...') mp.osd_message('Downloading plugins!') + + -- start iterating through plugins for i = 1, tablelength(plugins) do -- check if the user has defined a file for the current plugin if not plugins[i]['file'] then logwrite('WARNING! Git repo "' .. plugins[i][1] .. '" doesn\'t have a specified file. Skipping download') + -- FIXME: this results in the last plugin being downloaded & copied twice i = i + 1 -- if not we go to the next plugin end @@ -153,7 +157,7 @@ local function initupdate() -- closing/removing everything 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) end @@ -161,6 +165,8 @@ local function initupdate() end -- 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() openlog() for i = 1, tablelength(plugins) do @@ -173,9 +179,11 @@ local function runopts() end -- remove logfile on startup -openlog() -os.remove(fn) -closelog() +if opts.logging.log then + openlog() + os.remove(fn) + closelog() +end runopts() mp.add_key_binding(opts.bind, 'UpdatePlugins', initupdate) -- cgit v1.2.1