Skip to content

Commit

Permalink
added result check to tui
Browse files Browse the repository at this point in the history
Signed-off-by: quobix <[email protected]>
  • Loading branch information
daveshanley committed Feb 21, 2024
1 parent aee63b5 commit d821df2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tui/build_tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,18 @@ import (

func BuildTreeView(commit *model.Commit) *tview.TreeView {
root := BuildTreeModel(commit.Document, commit.Changes)
if root == nil {
return nil
}
tree := tview.NewTreeView()
tree.SetRoot(root).SetCurrentNode(root)
return tree
}

func BuildTreeModel(doc libopenapi.Document, changes *whatChangedModel.DocumentChanges) *tview.TreeNode {
if doc == nil {
return nil
}
root := tview.NewTreeNode(doc.GetSpecInfo().SpecType).SetColor(CYAN_CELL_COLOR)
if changes != nil {
buildTreeNode(root, changes)
Expand Down
5 changes: 5 additions & 0 deletions tui/main_console.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/gdamore/tcell/v2"
whatChanged "github.com/pb33f/libopenapi/what-changed/model"
"github.com/pb33f/openapi-changes/model"
"github.com/pterm/pterm"
"github.com/rivo/tview"
)

Expand All @@ -21,6 +22,10 @@ func BuildApplication(commitHistory []*model.Commit, version string) *tview.Appl

// tree view
tree := BuildTreeView(commit)
if tree == nil {
pterm.Error.Println("Cannot render console, no results were extracted.")
return nil
}

// build table filled with commit / history
table := BuildCommitTable(commitHistory)
Expand Down

0 comments on commit d821df2

Please sign in to comment.