Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .nextchanges/air/active-runs-empty-message.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* `air list` now reports `No active runs found.` for an empty active-only result. ([#7276](https://github.com/databricks/cli/pull/7276))
2 changes: 1 addition & 1 deletion cmd/air/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ Filters:
warnIfTruncated(ctx, fetcher)
return renderEnvelope(ctx, listData{Rows: rows})
}
return renderListText(cmd, fetcher, limit)
return renderListText(cmd, fetcher, limit, !allStatus)
}

return cmd
Expand Down
15 changes: 13 additions & 2 deletions cmd/air/list_tui.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
// renderListText renders the table for text output: an inline navigable table in
// a terminal (paging in older runs on demand), otherwise printed once. JSON is
// handled by the caller.
func renderListText(cmd *cobra.Command, f *runFetcher, limit int) error {
func renderListText(cmd *cobra.Command, f *runFetcher, limit int, activeOnly bool) error {
ctx := cmd.Context()
out := cmd.OutOrStdout()

Expand All @@ -36,7 +36,7 @@ func renderListText(cmd *cobra.Command, f *runFetcher, limit int) error {
return err
}
if len(first) == 0 {
_, err := io.WriteString(out, "No runs found.\n")
_, err := io.WriteString(out, emptyListMessage(activeOnly))
return err
}
_, err = tea.NewProgram(
Expand All @@ -53,10 +53,21 @@ func renderListText(cmd *cobra.Command, f *runFetcher, limit int) error {
return err
}
warnIfTruncated(ctx, f)
if len(rows) == 0 {
_, err = io.WriteString(out, emptyListMessage(activeOnly))
return err
}
_, err = io.WriteString(out, staticListTable(r, rows, color))
return err
}

func emptyListMessage(activeOnly bool) string {
if activeOnly {
return "No active runs found. Use --all-status to include runs that are no longer active.\n"
}
return "No runs found.\n"
}

// staticListTable renders the whole table once, with no selection — used when
// piped or non-interactive.
func staticListTable(r *lipgloss.Renderer, rows []listRow, links bool) string {
Expand Down
5 changes: 5 additions & 0 deletions cmd/air/list_tui_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,11 @@ func TestStaticListTable(t *testing.T) {
assert.Equal(t, "No runs found.\n", staticListTable(r, nil, false))
}

func TestEmptyListMessage(t *testing.T) {
assert.Equal(t, "No active runs found. Use --all-status to include runs that are no longer active.\n", emptyListMessage(true))
assert.Equal(t, "No runs found.\n", emptyListMessage(false))
}

func TestStatusColor(t *testing.T) {
assert.Equal(t, colGreen, statusColor("SUCCESS"))
assert.Equal(t, colAmber, statusColor("RUNNING"))
Expand Down
Loading