-
Notifications
You must be signed in to change notification settings - Fork 0
/
cmd_tree.go
48 lines (39 loc) · 981 Bytes
/
cmd_tree.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package main
import (
"bytes"
"fmt"
"github.com/emicklei/artreyu/model"
"github.com/spf13/cobra"
)
func newTreeCmd() *cobra.Command {
return &cobra.Command{
Use: "tree",
Short: "reads artifact descriptors recursively and prints the dependency hierarchy",
Run: doPrintTree,
}
}
type node struct {
label string
parts []node
}
func (n *node) add(part node) {
n.parts = append(n.parts, part)
}
func (n *node) String() string {
buf := new(bytes.Buffer)
n.printOn(0, buf)
return buf.String()
}
func (n *node) printOn(level int, buf *bytes.Buffer) {
}
// TODO fetch the descriptors of each component
func doPrintTree(cmd *cobra.Command, args []string) {
assembly, err := model.LoadAssembly(applicationSettings.ArtifactConfigLocation)
if err != nil {
model.Fatalf("tree failed, unable to load assembly descriptor:%v", err)
}
fmt.Println("|", assembly.StorageBase())
for _, each := range assembly.Parts {
fmt.Println("|-- ", each.StorageBase())
}
}