feat: add -output-template flag for custom output format - #996
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (2)
WalkthroughAdds ChangesCustom Output Template
Estimated code review effort: 3 (Moderate) | ~20 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
internal/runner/runner.go (1)
794-801: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueRouting is correct: the record-type gating now also covers
OutputTemplate, and the template branch is placed before the JSON/Raw/text branches. One small doc nit — the comment on Lines 790-793 still says "JSON and raw output," but the gate now also applies to the template path; consider updating it to avoid future confusion.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@internal/runner/runner.go` around lines 794 - 801, Update the nearby comment in runner.go so it matches the current gating logic: the record-type check in the record handling flow now applies to OutputTemplate as well as JSON and Raw output. Adjust the comment around the branch in runner.outputRecord to mention template output too, keeping the wording aligned with the conditions used by r.options.JSON, r.options.Raw, and r.options.OutputTemplate.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@internal/runner/runner.go`:
- Around line 794-801: Update the nearby comment in runner.go so it matches the
current gating logic: the record-type check in the record handling flow now
applies to OutputTemplate as well as JSON and Raw output. Adjust the comment
around the branch in runner.outputRecord to mention template output too, keeping
the wording aligned with the conditions used by r.options.JSON, r.options.Raw,
and r.options.OutputTemplate.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 999439f9-2c41-47bd-a125-193d829813a3
⛔ Files ignored due to path filters (1)
go.sumis excluded by!**/*.sum
📒 Files selected for processing (6)
README.mdgo.modinternal/runner/options.gointernal/runner/output_template.gointernal/runner/output_template_test.gointernal/runner/runner.go
Closes #992
Summary
Adds an
-output-template/-otflag that lets users define a custom output format instead of the fixed bracketed layout (example.com [A] [104.20.23.154]), mirroring katana's-output-template.This resolves the request to reorder/select fields, drop the brackets, and clean up output without post-processing (
tr -d "[]").Details
host,a,aaaa,cname,ns,txt,mx,cdn-name,asn,query-time, ...), plus a convenience{{ip}}alias for combined A/AAAA records.-json/-raw(validated).valyala/fasttemplate(same lib katana uses).Testing
internal/runner/output_template_test.go.go build ./...,golangci-lint run ./...(0 issues), andgo test ./internal/runner/all pass.Summary by CodeRabbit
New Features
-ot/--output-templateto customize DNS output with{{field}}placeholders, including combinedip(A+AAAA) formatting.Bug Fixes
--output-templatecan’t be used with--jsonor--raw/--debugoutput modes.Documentation
dnsx -husage text and added a “Custom Output Format” section with examples and template variable list.Tests