From d6f65c3279216e25db997c113e55a8e73f8ea1b6 Mon Sep 17 00:00:00 2001 From: bashbunni Date: Tue, 23 Jul 2024 13:38:29 -0700 Subject: [PATCH] refactor(examples): tidy root order --- examples/list/tree/main.go | 74 ++++++++++++++++++++++---------------- 1 file changed, 44 insertions(+), 30 deletions(-) diff --git a/examples/list/tree/main.go b/examples/list/tree/main.go index f99c4b70..f96dbdd2 100644 --- a/examples/list/tree/main.go +++ b/examples/list/tree/main.go @@ -7,45 +7,59 @@ import ( ) func main() { - t := list.New( - "Documents", - "Downloads", - "Unfinished Projects", - ).Root("~").Enumerator(list.Tree) + t := list.New(). + Root("~"). + Items( + "Documents", + "Downloads", + "Unfinished Projects"). + Enumerator(list.Tree) fmt.Println("A classic tree:\n" + t.String() + "\n") - tr := list.New( - "Documents", - "Downloads", - "Unfinished Projects", - ).Root("~").Enumerator(list.TreeRounded) + tr := list.New(). + Root("~"). + Items( + "Documents", + "Downloads", + "Unfinished Projects"). + Enumerator(list.TreeRounded) fmt.Println("A cool, rounded tree:\n" + tr.String() + "\n") - ti := list.New( - list.New( - "Important Documents", - "Junk Drawer", - "Books", - ).Root("Documents").Enumerator(list.Tree), - "Downloads", - "Unfinished Projects", - ).Root("~").Enumerator(list.Tree).Indenter(list.TreeIndenter) + ti := list.New(). + Root("~"). + Items( + list.New(). + Root("Documents"). + Items( + "Important Documents", + "Junk Drawer", + "Books", + ).Enumerator(list.Tree), + "Downloads", + "Unfinished Projects"). + Enumerator(list.Tree). + Indenter(list.TreeIndenter) fmt.Println("A fancy, nested tree:\n" + ti.String() + "\n") - documents := list.New( - "Important Documents", - "Junk Drawer", - "Books", - ).Root("Documents").Enumerator(list.Tree) - - treeAsRoot := list.New( - "More Documents", - "Unfinished Projects", - list.New("Bubble Tea in Rust", "Zig Projects"), - ).Root(documents).Enumerator(list.Tree).Indenter(list.TreeIndenter) + documents := list.New(). + Root("Documents"). + Items( + "Important Documents", + "Junk Drawer", + "Books"). + Enumerator(list.Tree) + + treeAsRoot := list.New(). + Root(documents). + Items( + "More Documents", + "Unfinished Projects", + list.New("Bubble Tea in Rust", "Zig Projects").Enumerator(list.Tree)). + Enumerator(list.Tree). + Indenter(list.TreeIndenter) fmt.Println("A chaotic tree:\n" + treeAsRoot.String() + "\n") }