diff options
| author | s <[email protected]> | 2025-11-25 09:58:42 -0500 |
|---|---|---|
| committer | s <[email protected]> | 2025-11-25 09:58:42 -0500 |
| commit | 8a342848809a26e7e13933180b4df91d4a52f898 (patch) | |
| tree | 6d273e54d6ffb6ae694e21ce587e28348b01aea5 /internal/formatter/dns.go | |
| parent | 8472267b60b204cea5fbdeaf8fe06443822d1bfb (diff) | |
| download | dborg-8a342848809a26e7e13933180b4df91d4a52f898.tar.gz dborg-8a342848809a26e7e13933180b4df91d4a52f898.zip | |
feat: add dns site check, services list, and additional twitter/x api endpointsv1.0.6
Diffstat (limited to 'internal/formatter/dns.go')
| -rw-r--r-- | internal/formatter/dns.go | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/internal/formatter/dns.go b/internal/formatter/dns.go index 6abd5b0..8e66039 100644 --- a/internal/formatter/dns.go +++ b/internal/formatter/dns.go @@ -1,6 +1,7 @@ package formatter import ( + "bytes" "encoding/json" "fmt" "strings" @@ -55,3 +56,37 @@ func FormatDNSResults(result *models.DomainResult, asJSON bool) (string, error) return sb.String(), nil } + +func FormatDNSSite(resp *models.DNSResponse, asJSON bool) (string, error) { + if asJSON { + data, err := json.MarshalIndent(resp, "", " ") + if err != nil { + return "", fmt.Errorf("failed to marshal JSON: %w", err) + } + return string(data), nil + } + + var buf bytes.Buffer + + if resp.Error != "" { + fmt.Fprintf(&buf, "%s\n", Red(fmt.Sprintf("Error: %s", resp.Error))) + return buf.String(), nil + } + + if resp.Message != "" { + fmt.Fprintf(&buf, "%s\n", Bold(Cyan(resp.Message))) + } + + if resp.Response != "" { + fmt.Fprintf(&buf, "%s\n", resp.Response) + } + + if resp.Data != nil && len(resp.Data) > 0 { + dataJSON, err := json.MarshalIndent(resp.Data, "", " ") + if err == nil { + fmt.Fprintf(&buf, "\n%s\n", string(dataJSON)) + } + } + + return buf.String(), nil +} |
