mirror of
https://github.com/Hilbis/Hilbish
synced 2025-05-11 14:53:22 +00:00
feat: allow processors to set if history should be saved
This commit is contained in:
parent
95a85eedd2
commit
fdbf333e38
@ -36,9 +36,11 @@ function hilbish.processors.execute(command, opts)
|
|||||||
opts.skip = opts.skip or {}
|
opts.skip = opts.skip or {}
|
||||||
|
|
||||||
local continue = true
|
local continue = true
|
||||||
|
local history
|
||||||
for _, processor in ipairs(hilbish.processors.list) do
|
for _, processor in ipairs(hilbish.processors.list) do
|
||||||
if not contains(opts.skip, processor.name) then
|
if not contains(opts.skip, processor.name) then
|
||||||
local processed = processor.func(command)
|
local processed = processor.func(command)
|
||||||
|
if processed.history ~= nil then history = processed.history end
|
||||||
if processed.command then command = processed.command end
|
if processed.command then command = processed.command end
|
||||||
if not processed.continue then
|
if not processed.continue then
|
||||||
continue = false
|
continue = false
|
||||||
@ -47,5 +49,9 @@ function hilbish.processors.execute(command, opts)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return command, continue
|
return {
|
||||||
|
command = command,
|
||||||
|
continue = continue,
|
||||||
|
history = history
|
||||||
|
}
|
||||||
end
|
end
|
||||||
|
@ -123,20 +123,21 @@ end
|
|||||||
-- @param priv bool
|
-- @param priv bool
|
||||||
function hilbish.runner.run(input, priv)
|
function hilbish.runner.run(input, priv)
|
||||||
bait.throw('command.preprocess', input)
|
bait.throw('command.preprocess', input)
|
||||||
local input, continue = hilbish.processors.execute(input, {
|
local processed = hilbish.processors.execute(input, {
|
||||||
skip = hilbish.opts.processorSkipList
|
skip = hilbish.opts.processorSkipList
|
||||||
})
|
})
|
||||||
if not continue then
|
priv = processed.history ~= nil and (not processed.history) or priv
|
||||||
|
if not processed.continue then
|
||||||
finishExec(0, '', true)
|
finishExec(0, '', true)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local command = hilbish.aliases.resolve(input)
|
local command = hilbish.aliases.resolve(processed.command)
|
||||||
bait.throw('command.preexec', input, command)
|
bait.throw('command.preexec', processed.command, command)
|
||||||
|
|
||||||
::rerun::
|
::rerun::
|
||||||
local runner = hilbish.runner.get(currentRunner)
|
local runner = hilbish.runner.get(currentRunner)
|
||||||
local ok, out = pcall(runner.run, input)
|
local ok, out = pcall(runner.run, processed.command)
|
||||||
if not ok then
|
if not ok then
|
||||||
io.stderr:write(out .. '\n')
|
io.stderr:write(out .. '\n')
|
||||||
finishExec(124, out.input, priv)
|
finishExec(124, out.input, priv)
|
||||||
@ -144,9 +145,9 @@ function hilbish.runner.run(input, priv)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if out.continue then
|
if out.continue then
|
||||||
local contInput = continuePrompt(input, out.newline)
|
local contInput = continuePrompt(processed.command, out.newline)
|
||||||
if contInput then
|
if contInput then
|
||||||
input = contInput
|
processed.command = contInput
|
||||||
goto rerun
|
goto rerun
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user