diff --git a/pkg/dns/show.go b/pkg/dns/show.go index c29a3f0..d133a2c 100644 --- a/pkg/dns/show.go +++ b/pkg/dns/show.go @@ -14,20 +14,24 @@ import ( // Show shows current DNS entries func (mgr *Manager) Show(ctx context.Context, names ...string) error { - var buf bytes.Buffer - recs, err := mgr.GetRecords(ctx, names...) if err != nil { return core.Wrap(err, "GetRecords") } + return writeRecords(recs, os.Stdout) +} + +func writeRecords(recs []libdns.Record, w io.Writer) error { + var buf bytes.Buffer + for _, rr := range recs { _ = fmtRecord(&buf, rr) _, _ = buf.WriteRune('\n') } _, _ = fmt.Fprintf(&buf, "; %v records\n", len(recs)) - _, err = buf.WriteTo(os.Stdout) + _, err := buf.WriteTo(w) return err }