2
2
mirror of https://github.com/Hilbis/Hilbish synced 2025-07-04 10:12:03 +00:00

Compare commits

..

No commits in common. "95a85eedd21e03c2aebc2cd6357a37fcee83d7d9" and "38b5aec99eda2b2a71e0e81004069c58539d3837" have entirely different histories.

5 changed files with 8 additions and 36 deletions

View File

@ -76,8 +76,3 @@ of an exact match.
#### Default: `true` #### Default: `true`
If this is enabled, when a background job is finished, If this is enabled, when a background job is finished,
a [notification](../notifications) will be sent. a [notification](../notifications) will be sent.
### `processorSkipList`
#### Value: `table`
#### Default: `{}`
A table listing the names of command processors to skip.

View File

@ -1,7 +1,6 @@
local fs = require 'fs' local fs = require 'fs'
hilbish.processors.add { hilbish.processors.add {
name = 'hilbish.autocd',
func = function(path) func = function(path)
if hilbish.opts.autocd then if hilbish.opts.autocd then
local ok, stat = pcall(fs.stat, path) local ok, stat = pcall(fs.stat, path)

View File

@ -15,8 +15,7 @@ The nice lil shell for {blue}Lua{reset} fanatics!
fuzzy = false, fuzzy = false,
notifyJobFinish = true, notifyJobFinish = true,
crimmas = true, crimmas = true,
tips = true, tips = true
processorSkipList = {}
} }
for optsName, default in pairs(defaultOpts) do for optsName, default in pairs(defaultOpts) do

View File

@ -6,10 +6,6 @@ hilbish.processors = {
} }
function hilbish.processors.add(processor) function hilbish.processors.add(processor)
if not processor.name then
error 'processor is missing name'
end
if not processor.func then if not processor.func then
error 'processor is missing function' error 'processor is missing function'
end end
@ -18,32 +14,17 @@ function hilbish.processors.add(processor)
table.sort(hilbish.processors.list, function(a, b) return a.priority < b.priority end) table.sort(hilbish.processors.list, function(a, b) return a.priority < b.priority end)
end end
local function contains(search, needle)
for _, p in ipairs(search) do
if p == needle then
return true
end
end
return false
end
--- Run all command processors, in order by priority. --- Run all command processors, in order by priority.
--- It returns the processed command (which may be the same as the passed command) --- It returns the processed command (which may be the same as the passed command)
--- and a boolean which states whether to proceed with command execution. --- and a boolean which states whether to proceed with command execution.
function hilbish.processors.execute(command, opts) function hilbish.processors.execute(command)
opts = opts or {}
opts.skip = opts.skip or {}
local continue = true local continue = true
for _, processor in ipairs(hilbish.processors.list) do for _, processor in ipairs(hilbish.processors.list) do
if not contains(opts.skip, processor.name) then local processed = processor.func(command)
local processed = processor.func(command) 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 break
break
end
end end
end end

View File

@ -123,9 +123,7 @@ 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 input, continue = hilbish.processors.execute(input)
skip = hilbish.opts.processorSkipList
})
if not continue then if not continue then
finishExec(0, '', true) finishExec(0, '', true)
return return