-
Notifications
You must be signed in to change notification settings - Fork 53
Expand file tree
/
Copy pathglob.lua
More file actions
38 lines (29 loc) · 1.15 KB
/
glob.lua
File metadata and controls
38 lines (29 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
local icons = require('opencode.ui.icons')
local M = {}
---@param output Output
---@param part OpencodeMessagePart
function M.format(output, part)
if part.tool ~= 'glob' then
return
end
local input = part.state and part.state.input or {}
local metadata = part.state and part.state.metadata or {}
local utils = require('opencode.ui.formatter.utils')
local config = require('opencode.config')
local icons = require('opencode.ui.icons')
utils.format_action(output, icons.get('search'), 'glob', input.pattern, utils.get_duration_text(part))
local start_line = output:get_line_count() + 1
if not (config.ui.output.tools.show_output or config.ui.output.tools.use_folds) then
return
end
local prefix = metadata.truncated and ' more than' or ''
output:add_line(string.format('Found%s `%d` file(s):', prefix, metadata.count or 0))
output:add_fold_with_threshold(start_line, config.ui.output.tools.show_output, config.ui.output.tools.use_folds)
end
---@param _ OpencodeMessagePart
---@param input GlobToolInput
---@return string, string, string
function M.summary(_, input)
return icons.get('search'), 'glob', input.pattern or ''
end
return M