Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
Node is a handle associated with a specific depth in a tree. See below for sample usage.
func New ¶
func New() Node
New creates a tree printer and returns a sentinel node reference which should be used to add the root. Sample usage:
tp := New() root := tp.Child("root") root.Child("child-1") root.Child("child-2").Child("grandchild\ngrandchild-more-info") root.Child("child-3") fmt.Print(tp.String())
Output:
root ├── child-1 ├── child-2 │ └── grandchild │ grandchild-more-info └── child-3
Note that the Child calls can't be rearranged arbitrarily; they have to be in the order they need to be displayed (depth-first pre-order).
func NewWithStyle ¶
NewWithStyle creates a tree printer like New, permitting customization of the style of the resulting tree.
func (Node) AddEmptyLine ¶
func (n Node) AddEmptyLine()
AddEmptyLine adds an empty line to the output; used to introduce vertical spacing as needed.
func (Node) Child ¶
Child adds a node as a child of the given node. Multi-line strings are supported with appropriate indentation.
func (Node) FormattedRows ¶
FormattedRows returns the formatted rows. Can only be called on the result of treeprinter.New.
type Style ¶
type Style int
Style is one of the predefined treeprinter styles.
const ( // DefaultStyle is the default style. Example: // // foo // ├── bar1 // │ bar2 // │ └── baz // └── qux // DefaultStyle Style = iota // CompactStyle is a compact style, for deeper trees. Example: // // foo // ├ bar1 // │ bar2 // │ └ baz // └ qux // CompactStyle // BulletStyle is a style that shows a bullet for each node, and groups any // other lines under that bullet. Example: // // • foo // │ // ├── • bar1 // │ │ bar2 // │ │ // │ └── • baz // │ // └── • qux // BulletStyle )