From 1e77a7b9e58e62654ca800f05b31c7467116c4bc Mon Sep 17 00:00:00 2001 From: dvs1 Date: Mon, 4 Nov 2024 12:32:17 +1000 Subject: Add uninstall and purge subcommands for PolygLua and aataaj. --- PolygLua.lua | 104 ++++++++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 85 insertions(+), 19 deletions(-) (limited to 'PolygLua.lua') diff --git a/PolygLua.lua b/PolygLua.lua index bd7bd4d..86dc8be 100755 --- a/PolygLua.lua +++ b/PolygLua.lua @@ -313,27 +313,93 @@ end -if arg[0] == './PolygLua.lua' then - local w = __[[whoami]]:noErr():Do().lines[1] - local d = __[[pwd]]:noErr():Do().lines[1] - local luas = __'ls -d1 /usr/share/lua/*':noErr():Do() - for i,l in ipairs(luas.lines) do - local lua = '/usr/local/share/lua/' .. l:sub(16) .. '/PolygLua.lua' - if _.exists(lua) then - print(lua .. ' installed') - else - if 'root' == w then - print('Installing ' .. lua) - __('mkdir -p /usr/local/share/lua/' .. l:sub(16) .. ' ; ln -s ' .. d .. '/PolygLua.lua ' .. lua):Do() - else - print(lua .. ' NOT installed') +_.who = __[[whoami]]:noErr():Do().lines[1] +_.dir = __[[pwd]]:noErr():Do().lines[1] + + + +if (arg[0] == './PolygLua.lua') or (arg[0] == 'PolygLua.lua') then + local options = + { + install = + { + help = 'Command to install PolygLua.lua', + func = function(self, options, a, args, i) + if 'root' ~= _.who then + E'Need to be root user to install.' + else + print('INSTALLING PolygLua.lua!!!') + + local luas = __'ls -d1 /usr/share/lua/*':noErr():Do() + for i,l in ipairs(luas.lines) do + local lua = '/usr/local/share/lua/' .. l:sub(16) .. '/PolygLua.lua' + if _.exists(lua) then + print(lua .. ' installed') + else + if 'root' == _.who then + print('Installing ' .. lua) + __('mkdir -p /usr/local/share/lua/' .. l:sub(16) .. ' ; ln -s ' .. _.dir .. '/PolygLua.lua ' .. lua):Do() + else + print(lua .. ' NOT installed') + end + end + end + + end +-- os.exit(0) end - end - end + }, + uninstall = + { + help = 'Command to uninstall PolygLua.lua', + func = function(self, options, a, args, i) + if 'root' ~= _.who then + E'Need to be root user to uninstall.' + else + print('UNINSTALLING PolygLua.lua!!!') + + local luas = __'ls -d1 /usr/share/lua/*':noErr():Do() + for i,l in ipairs(luas.lines) do + local lua = '/usr/local/share/lua/' .. l:sub(16) .. '/PolygLua.lua' + if _.exists(lua) then + if 'root' == _.who then + print('Uninstalling ' .. lua) + __('rm ' .. lua):Do() + end + end + end - if 'root' ~= w then - E'Need to be root user to install.' - end + end +-- os.exit(0) + end + }, + purge = + { + help = 'Command to purge PolygLua.lua', + func = function(self, options, a, args, i) + if 'root' ~= _.who then + E'Need to be root user to purge.' + else + print('PURGING PolygLua.lua!!!') + + local luas = __'ls -d1 /usr/share/lua/*':noErr():Do() + for i,l in ipairs(luas.lines) do + local lua = '/usr/local/share/lua/' .. l:sub(16) .. '/PolygLua.lua' + if _.exists(lua) then + if 'root' == _.who then + print('Purging ' .. lua) + __('rm ' .. lua):Do() + end + end + end + + end +-- os.exit(0) + end + }, + } + + _.parse(arg, options) end -- cgit v1.1