MCPcopy Create free account
hub / github.com/celer-pkg/celer / printTreeWithPrefix

Method printTreeWithPrefix

cmds/cmd_tree.go:296–333  ·  view source on GitHub ↗
(info *portInfo, prefix string, isLast bool)

Source from the content-addressed store, hash-verified

294}
295
296func (t *treeCmd) printTreeWithPrefix(info *portInfo, prefix string, isLast bool) {
297 var branch string
298 if info.depth == 0 {
299 branch = ""
300 } else if isLast {
301 branch = "└── "
302 } else {
303 branch = "├── "
304 }
305
306 // Compose the line to print.
307 line := branch + info.nameVersion
308 if info.devDep {
309 line += " -- [dev]"
310 }
311 color.Println(color.Hint, prefix+line)
312
313 // Prepare the prefix for the next level.
314 var nextPrefix string
315 if info.depth == 0 {
316 nextPrefix = ""
317 } else if isLast {
318 nextPrefix = prefix + " " // No vertical line if this is the last child.
319 } else {
320 nextPrefix = prefix + "│ " // Keep vertical line for siblings.
321 }
322
323 // Merge normal and dev dependencies (if not hidden).
324 children := info.depedencies
325 if !t.hideDevDep {
326 children = append(children, info.devDependencies...)
327 }
328
329 // Recursively print children
330 for i, child := range children {
331 t.printTreeWithPrefix(child, nextPrefix, i == len(children)-1)
332 }
333}
334
335func (t *treeCmd) completion(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
336 var suggestions []string

Callers 1

printTreeMethod · 0.95

Calls 1

PrintlnFunction · 0.92

Tested by

no test coverage detected