diff options
author | Will Murphy <willmurphyscode@gmail.com> | 2018-06-01 16:56:00 -0400 |
---|---|---|
committer | Will Murphy <willmurphyscode@gmail.com> | 2018-06-01 16:56:00 -0400 |
commit | 1e4ad0ce72d4c10ed5390a99fc729e181df92c67 (patch) | |
tree | 0b3e0f1ca1b8eb744c8fd2f832540b5974d74924 /main.go | |
parent | 4ed43ada819b81325998042d322141edb332670d (diff) |
display list of layers in UI
Diffstat (limited to 'main.go')
-rw-r--r-- | main.go | 43 |
1 files changed, 12 insertions, 31 deletions
@@ -7,18 +7,19 @@ import ( "io" "os" + "log" + "github.com/docker/docker/client" - "golang.org/x/net/context" "github.com/jroimartin/gocui" - "log" + "golang.org/x/net/context" ) var data struct { tree *FileTree + manifest *Manifest absPosition uint } - func check(e error) { if e != nil { panic(e) @@ -110,20 +111,8 @@ func demo() { fmt.Println("See './image' for the cached image tar") } - - - - - - - - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - - - func getAbsPositionNode() (node *FileNode) { var visiter func(*FileNode) error var evaluator func(*FileNode) bool @@ -154,7 +143,10 @@ func showCurNodeInSideBar(g *gocui.Gui, v *gocui.View) error { v, _ := g.View("side") // todo: handle above error. v.Clear() - _, err := fmt.Fprintf(v, "FileNode:\n%+v\n", getAbsPositionNode()) + _, err := fmt.Fprintf(v, "FileNode:\n%+v\n\n", getAbsPositionNode()) + for ix, layerName := range data.manifest.Layers { + fmt.Fprintf(v, "%d: %s\n", ix+1, layerName[0:25]) + } return err }) // todo: blerg @@ -166,7 +158,7 @@ func cursorDown(g *gocui.Gui, v *gocui.View) error { cx, cy := v.Cursor() // if there isn't a next line - line, err := v.Line(cy+1) + line, err := v.Line(cy + 1) if err != nil { // todo: handle error } @@ -200,7 +192,6 @@ func cursorUp(g *gocui.Gui, v *gocui.View) error { return nil } - func toggleCollapse(g *gocui.Gui, v *gocui.View) error { node := getAbsPositionNode() node.collapsed = !node.collapsed @@ -218,7 +209,6 @@ func drawTree(g *gocui.Gui, v *gocui.View) error { return nil } - func quit(g *gocui.Gui, v *gocui.View) error { return gocui.ErrQuit } @@ -242,7 +232,6 @@ func keybindings(g *gocui.Gui) error { return nil } - func layout(g *gocui.Gui) error { maxX, maxY := g.Size() splitCol := 50 @@ -251,6 +240,7 @@ func layout(g *gocui.Gui) error { return err } v.Wrap = true + } if v, err := g.SetView("main", splitCol, -1, maxX, maxY); err != nil { if err != gocui.ErrUnknownView { @@ -269,16 +259,9 @@ func layout(g *gocui.Gui) error { return nil } - func main() { - data.tree = NewTree() - data.tree.AddPath("/etc/nginx/nginx.conf", nil) - data.tree.AddPath("/etc/nginx/public", nil) - data.tree.AddPath("/var/run/systemd", nil) - data.tree.AddPath("/var/run/bashful", nil) - data.tree.AddPath("/tmp", nil) - data.tree.AddPath("/tmp/nonsense", nil) - data.tree.AddPath("/tmp/wifi/coffeeyo", nil) + demo() + initialize() g, err := gocui.NewGui(gocui.OutputNormal) if err != nil { @@ -299,5 +282,3 @@ func main() { } } - - |