mirror of https://github.com/kepler155c/opus
package manager install/uninstall directives
This commit is contained in:
parent
57ea46dde7
commit
9ef4d9ef64
|
@ -9,6 +9,12 @@ local term = _G.term
|
||||||
local args = { ... }
|
local args = { ... }
|
||||||
local action = table.remove(args, 1)
|
local action = table.remove(args, 1)
|
||||||
|
|
||||||
|
local function makeSandbox()
|
||||||
|
local sandbox = setmetatable(Util.shallowCopy(_ENV), { __index = _G })
|
||||||
|
_G.requireInjector(sandbox)
|
||||||
|
return sandbox
|
||||||
|
end
|
||||||
|
|
||||||
local function Syntax(msg)
|
local function Syntax(msg)
|
||||||
_G.printError(msg)
|
_G.printError(msg)
|
||||||
print('\nSyntax: Package list | install [name] ... | update [name] | uninstall [name]')
|
print('\nSyntax: Package list | install [name] ... | update [name] | uninstall [name]')
|
||||||
|
@ -71,6 +77,17 @@ local function install(name, isUpdate, ignoreDeps)
|
||||||
end
|
end
|
||||||
showProgress()
|
showProgress()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
if not isUpdate then
|
||||||
|
if manifest.install then
|
||||||
|
local s, m = pcall(function()
|
||||||
|
load(manifest.install, 'install', nil, makeSandbox())
|
||||||
|
end)
|
||||||
|
if not s and m then
|
||||||
|
_G.printError(m)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if action == 'list' then
|
if action == 'list' then
|
||||||
|
@ -121,6 +138,15 @@ if action == 'uninstall' then
|
||||||
if not Packages:isInstalled(name) then
|
if not Packages:isInstalled(name) then
|
||||||
error('Package is not installed')
|
error('Package is not installed')
|
||||||
end
|
end
|
||||||
|
local manifest = Packages:getManifest(name)
|
||||||
|
if manifest.uninstall then
|
||||||
|
local s, m = pcall(function()
|
||||||
|
load(manifest.uninstall, 'uninstall', nil, makeSandbox())
|
||||||
|
end)
|
||||||
|
if not s and m then
|
||||||
|
_G.printError(m)
|
||||||
|
end
|
||||||
|
end
|
||||||
local packageDir = fs.combine('packages', name)
|
local packageDir = fs.combine('packages', name)
|
||||||
fs.delete(packageDir)
|
fs.delete(packageDir)
|
||||||
print('removed: ' .. packageDir)
|
print('removed: ' .. packageDir)
|
||||||
|
|
|
@ -44,7 +44,7 @@ function Alt.addChoice(key, value)
|
||||||
config.choices[key] = { }
|
config.choices[key] = { }
|
||||||
end
|
end
|
||||||
if not Util.contains(config.choices[key], value) then
|
if not Util.contains(config.choices[key], value) then
|
||||||
config.choices[key] = value
|
table.insert(config.choices[key], value)
|
||||||
Config.update('alternate', config)
|
Config.update('alternate', config)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue