mirror of
https://github.com/celogeek/piwigo-cli.git
synced 2025-05-25 10:12:37 +02:00
tree view for listing images
This commit is contained in:
parent
522fe01b22
commit
33ca442a87
@ -131,22 +131,25 @@ func (c *ImagesListCommand) Execute(args []string) error {
|
|||||||
treeLinkChar := "│ "
|
treeLinkChar := "│ "
|
||||||
treeMidChar := "├── "
|
treeMidChar := "├── "
|
||||||
treeEndChar := "└── "
|
treeEndChar := "└── "
|
||||||
|
treeAfterEndChar := " "
|
||||||
|
|
||||||
treeView = func(t *Tree, prefix string) {
|
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 {
|
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)
|
treeView(st, prefix+treeLinkChar)
|
||||||
} else {
|
|
||||||
treeView(st, prefix+treeEndChar)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fmt.Println(treeMap[""].Name)
|
||||||
treeView(treeMap[""], "")
|
treeView(treeMap[""], "")
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
Loading…
x
Reference in New Issue
Block a user