diff --git a/internal/piwigocli/images_list.go b/internal/piwigocli/images_list.go index 867e88b..9242e94 100644 --- a/internal/piwigocli/images_list.go +++ b/internal/piwigocli/images_list.go @@ -131,22 +131,25 @@ func (c *ImagesListCommand) Execute(args []string) error { treeLinkChar := "│ " treeMidChar := "├── " treeEndChar := "└── " + treeAfterEndChar := " " treeView = func(t *Tree, prefix string) { - if prefix == "" { - fmt.Println(t.Name) - } else { - fmt.Println(prefix + treeMidChar + t.Name) - } for i, st := range t.Children { - if i < len(t.Children)-1 { + switch i { + case len(t.Children) - 1: + fmt.Println(prefix + treeEndChar + st.Name) + treeView(st, prefix+treeAfterEndChar) + case 0: + fmt.Println(prefix + treeMidChar + st.Name) + treeView(st, prefix+treeLinkChar) + default: + fmt.Println(prefix + treeMidChar + st.Name) treeView(st, prefix+treeLinkChar) - } else { - treeView(st, prefix+treeEndChar) } } } + fmt.Println(treeMap[""].Name) treeView(treeMap[""], "") return nil