From dde56cbb4fd088809249af63f8e7e8b1269de9f7 Mon Sep 17 00:00:00 2001 From: TorchedSammy <38820196+TorchedSammy@users.noreply.github.com> Date: Sat, 21 May 2022 11:54:07 -0400 Subject: [PATCH] feat: make disown command get last job if id isnt suppied as arg --- nature/commands/disown.lua | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/nature/commands/disown.lua b/nature/commands/disown.lua index 3d72719..f8f144f 100644 --- a/nature/commands/disown.lua +++ b/nature/commands/disown.lua @@ -1,14 +1,25 @@ local commander = require 'commander' commander.register('disown', function(args) - local id = tonumber(args[1]) - if not id then - print 'invalid id for job' + if #hilbish.jobs.all() == 0 then + print 'disown: no current job' 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 + local ok = pcall(hilbish.jobs.disown, id) if not ok then - print 'job does not exist' + print 'disown: job does not exist' + return 2 end end)