Skip to content

Commit

Permalink
show row count only when paged
Browse files Browse the repository at this point in the history
  • Loading branch information
pskrbasu committed Feb 7, 2025
1 parent ec0b9f1 commit a3315de
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 19 deletions.
14 changes: 8 additions & 6 deletions querydisplay/display.go
Original file line number Diff line number Diff line change
Expand Up @@ -444,14 +444,16 @@ func displayTable[T queryresult.TimingContainer](ctx context.Context, result *qu
t.Render()

// page out the table
ShowPaged(ctx, outbuf.String())
showRowCount := ShowPaged(ctx, outbuf.String())

status := fmt.Sprintf("%s rows", utils.HumanizeNumber(count))
if displayRowCount >= maxTableDisplayRows {
status += fmt.Sprintf(" (%s shown)", utils.HumanizeNumber(maxTableDisplayRows))
if showRowCount {
status := fmt.Sprintf("%s %s", utils.HumanizeNumber(count), utils.Pluralize("row", count))
if displayRowCount >= maxTableDisplayRows {
status += fmt.Sprintf(" (%s shown)", utils.HumanizeNumber(maxTableDisplayRows))
}
//nolint:forbidigo // acceptable
fmt.Println(status)
}
//nolint:forbidigo // acceptable
fmt.Println(status)

return count, rowErrors
}
Expand Down
6 changes: 4 additions & 2 deletions querydisplay/pager.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,18 @@ import (
)

// ShowPaged displays the `content` in a system dependent pager
func ShowPaged(ctx context.Context, content string) {
func ShowPaged(ctx context.Context, content string) bool {
if isPagerNeeded(content) && (runtime.GOOS == "darwin" || runtime.GOOS == "linux") {
nixPager(ctx, content)
return true
} else {
nullPager(content)
return false
}
}

func isPagerNeeded(content string) bool {
// TODO use option, NOT viper https://github.com/turbot/pipe-fittings/v2/issues/613
// TODO use option, NOT viper https://github.com/turbot/pipe-fittings/issues/613
// only show pager in interactive mode
if !viper.GetBool(constants.ConfigKeyInteractive) {
return false
Expand Down
11 changes: 0 additions & 11 deletions version.json

This file was deleted.

0 comments on commit a3315de

Please # to comment.