Hilbish/nature/commands/disown.lua

26 lines
453 B
Lua
Raw Normal View History

2022-05-21 15:38:26 +00:00
local commander = require 'commander'
commander.register('disown', function(args)
if #hilbish.jobs.all() == 0 then
print 'disown: no current job'
2022-05-21 15:38:26 +00:00
return 1
end
local id
if #args < 0 then
id = tonumber(args[1])
if not id then
print 'disown: invalid id for job'
return 1
end
else
id = hilbish.jobs.last().id
end
2022-05-21 15:38:26 +00:00
local ok = pcall(hilbish.jobs.disown, id)
if not ok then
print 'disown: job does not exist'
return 2
2022-05-21 15:38:26 +00:00
end
end)