MCPcopy Create free account
hub / github.com/astercloud/aster / limitLines

Method limitLines

pkg/tools/builtin/bashoutput.go:292–304  ·  view source on GitHub ↗

limitLines 限制输出行数

(output string, maxLines int)

Source from the content-addressed store, hash-verified

290
291// limitLines 限制输出行数
292func (t *BashOutputTool) limitLines(output string, maxLines int) string {
293 if maxLines <= 0 || output == "" {
294 return output
295 }
296
297 lines := strings.Split(output, "\n")
298 if len(lines) <= maxLines {
299 return output
300 }
301
302 // 返回最后的maxLines行
303 return strings.Join(lines[len(lines)-maxLines:], "\n")
304}
305
306// filterByTime 按时间过滤输出
307func (t *BashOutputTool) filterByTime(output, since string) string {

Callers 1

ExecuteMethod · 0.95

Calls 1

JoinMethod · 0.45

Tested by

no test coverage detected