CLI: don't print "and N more" when the server sends no PTR list

A 0.6.1-rc.2 server sends ptr_other_views without ptr_other_views_list,
so zone show printed only "and 1 more" under "Other views:".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
adamandClaude Opus 5.5 committed 2026-10-20 15:05:50 +01:00
1 parent 71d9a06e43
commit 7f3564c0a5
3 files changed
+36 -1

No files matched your search

+5
View File
@@ -97,6 +97,11 @@ All notable changes to Jarl are documented here. The format follows
### Fixed ### Fixed
- `jarl zone show` for a reverse zone printed only "and 1 more" under
"Other views:" when the server was older than the CLI (0.6.1-rc.2
sends the count but not the addresses). It now prints just the count
line then.
- The statistics' "Busiest times" grid drew hours without data taller - The statistics' "Busiest times" grid drew hours without data taller
than the others (they picked up the page's padding for empty than the others (they picked up the page's padding for empty
messages). messages).
+25
View File
@@ -0,0 +1,25 @@
package main
import (
"bytes"
"strings"
"testing"
"jarl/internal/api"
)
func TestPrintPTRFills(t *testing.T) {
var b bytes.Buffer
printPTRFills(&b, []api.PTRFill{{Address: "10.0.10.20", Target: "nextcloud.adbraun.lol.", From: "internal"}}, 3)
out := b.String()
if !strings.Contains(out, "10.0.10.20 -> nextcloud.adbraun.lol (view internal)") || !strings.Contains(out, "and 2 more") {
t.Errorf("listed fills:\n%s", out)
}
// An older server sends the count without the list.
b.Reset()
printPTRFills(&b, nil, 1)
if b.Len() != 0 {
t.Errorf("no list from the server printed %q, want nothing", b.String())
}
}
+6 -1
View File
@@ -1183,8 +1183,13 @@ func terminalWidth() int {
} }
// printPTRFills lists PTR records a reverse zone lacks under zone show's // printPTRFills lists PTR records a reverse zone lacks under zone show's
// line about them: address -> name, and the view the name is from. // line about them: address -> name, and the view the name is from. A server
// older than the CLI may send the count without the list; then nothing is
// listed, rather than "and N more" under no addresses.
func printPTRFills(w io.Writer, fills []api.PTRFill, total int) { func printPTRFills(w io.Writer, fills []api.PTRFill, total int) {
if len(fills) == 0 {
return
}
for _, f := range fills { for _, f := range fills {
from := "" from := ""
if f.From != "" { if f.From != "" {