MCPcopy Create free account
hub / github.com/chainreactors/spray / formatTree

Function formatTree

core/format.go:187–220  ·  view source on GitHub ↗

formatTree renders results in tree structure

(group map[string]map[string]*baseline.Baseline, opts Option)

Source from the content-addressed store, hash-verified

185
186// formatTree renders results in tree structure
187func formatTree(group map[string]map[string]*baseline.Baseline, opts Option) {
188 // Sort host:port for consistent output
189 var hosts []string
190 for host := range group {
191 hosts = append(hosts, host)
192 }
193 sort.Strings(hosts)
194
195 for _, host := range hosts {
196 results := group[host]
197
198 // Build tree for this host
199 root := NewTreeNode("")
200 for path, result := range results {
201 if !opts.Fuzzy && result.IsFuzzy {
202 continue
203 }
204
205 // Split path into parts
206 parts := strings.Split(strings.Trim(path, "/"), "/")
207 if path == "/" {
208 parts = []string{"/"}
209 }
210
211 root.AddPath(parts, result)
212 }
213
214 // Print host header
215 logs.Log.Console(fmt.Sprintf("\n%s\n", host))
216
217 // Render tree
218 logs.Log.Console(root.RenderTree("", true, !opts.NoColor))
219 }
220}
221
222// formatFull renders results in full/original format
223func formatFull(group map[string]map[string]*baseline.Baseline, opts Option) {

Callers 1

FormatFunction · 0.85

Calls 3

AddPathMethod · 0.95
RenderTreeMethod · 0.95
NewTreeNodeFunction · 0.85

Tested by

no test coverage detected