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

Method filterOutput

pkg/tools/builtin/task_manager.go:566–586  ·  view source on GitHub ↗

filterOutput 过滤输出

(output, filter string)

Source from the content-addressed store, hash-verified

564
565// filterOutput 过滤输出
566func (tm *FileTaskManager) filterOutput(output, filter string) string {
567 if filter == "" || output == "" {
568 return output
569 }
570
571 regex, err := regexp.Compile(filter)
572 if err != nil {
573 return output
574 }
575
576 lines := strings.Split(output, "\n")
577 var filteredLines []string
578
579 for _, line := range lines {
580 if regex.MatchString(line) {
581 filteredLines = append(filteredLines, line)
582 }
583 }
584
585 return strings.Join(filteredLines, "\n")
586}
587
588// limitLines 限制行数
589func (tm *FileTaskManager) limitLines(output string, maxLines int) string {

Callers 1

GetTaskOutputMethod · 0.95

Calls 1

JoinMethod · 0.45

Tested by

no test coverage detected