Skip to content

Commit

Permalink
handle 0 containers on start
Browse files Browse the repository at this point in the history
  • Loading branch information
somnek committed Jan 16, 2024
1 parent 1a11c1c commit 09222f3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
6 changes: 5 additions & 1 deletion model.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,11 @@ func initialModel() model {
// containers
containers := getContainers()
images := getImages()
containers[cursor].desc = buildContainerDescShort(containers[cursor].id)

// 0 container scenario
if len(containers) > 0 {
containers[cursor].desc = buildContainerDescShort(containers[cursor].id)
}

// spinner
s := spinner.New()
Expand Down
6 changes: 6 additions & 0 deletions view.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,12 @@ func (m model) View() string {
final += lipgloss.JoinVertical(lipgloss.Top, body, bottom)
appStyle.MarginLeft((m.width - fixedWidth) / 2)

// 0 containers
if len(m.containers) == 0 {
body = bodyStyle.Render("No containers found")
return title + "\n" + titleStyle.Render(body) + "\n"
}

return title + "\n" + appStyle.Render(final) + "\n" + help
}

Expand Down

0 comments on commit 09222f3

Please sign in to comment.