package formatter import ( "fmt" "strings" "git.db.org.ai/dborg/internal/models" "git.db.org.ai/dborg/internal/utils" ) func FormatUsernameSiteResult(result *models.SiteResult) error { if result.Status == "found" { fmt.Printf("%s | %s", Green("✓ FOUND"), result.SiteName) if result.URL != "" { fmt.Printf(" | %s", Blue(result.URL)) } fmt.Println() if len(result.Metadata) > 0 { fmt.Print(formatMetadata(result.Metadata)) } } return nil } func FormatUsernameResults(response *models.USRSXResponse, asJSON bool) error { if asJSON { return utils.PrintJSON(response) } if response.Error != "" { return fmt.Errorf("%s", response.Error) } if response.Message != "" { return nil } if len(response.Results) == 0 { return nil } for _, result := range response.Results { if result.Status == "found" { fmt.Printf("%s | %s", Green("✓ FOUND"), result.SiteName) if result.URL != "" { fmt.Printf(" | %s", Blue(result.URL)) } fmt.Println() if len(result.Metadata) > 0 { fmt.Print(formatMetadata(result.Metadata)) } } } return nil } func formatMetadata(metadata map[string]interface{}) string { var lines []string boxStyle := Dim(" ├─ ") labelStyle := Dim if displayName, ok := metadata["display_name"].(string); ok && displayName != "" { lines = append(lines, boxStyle+labelStyle("Name: ")+displayName) } if bio, ok := metadata["bio"].(string); ok && bio != "" { bioPreview := bio if len(bioPreview) > 100 { bioPreview = bioPreview[:97] + "..." } lines = append(lines, boxStyle+labelStyle("Bio: ")+bioPreview) } if avatar, ok := metadata["avatar_url"].(string); ok && avatar != "" { lines = append(lines, boxStyle+labelStyle("Avatar: ")+avatar) } if location, ok := metadata["location"].(string); ok && location != "" { lines = append(lines, boxStyle+labelStyle("Location: ")+location) } if website, ok := metadata["website"].(string); ok && website != "" { lines = append(lines, boxStyle+labelStyle("Website: ")+website) } if joinDate, ok := metadata["join_date"].(string); ok && joinDate != "" { lines = append(lines, boxStyle+labelStyle("Joined: ")+joinDate) } if followers, ok := metadata["follower_count"].(float64); ok && followers > 0 { lines = append(lines, boxStyle+labelStyle("Followers: ")+fmt.Sprintf("%d", int(followers))) } if following, ok := metadata["following_count"].(float64); ok && following > 0 { lines = append(lines, boxStyle+labelStyle("Following: ")+fmt.Sprintf("%d", int(following))) } if verified, ok := metadata["is_verified"].(bool); ok && verified { lines = append(lines, boxStyle+labelStyle("Verified: ")+Green("✓ Yes")) } if additionalLinks, ok := metadata["additional_links"].(map[string]interface{}); ok && len(additionalLinks) > 0 { linkCount := 0 linkLines := []string{} for key, value := range additionalLinks { if strVal, ok := value.(string); ok { linkLines = append(linkLines, Dim(" ├─ ")+labelStyle(key+": ")+strVal) linkCount++ } } if linkCount > 0 { lastBoxStyle := Dim(" └─ ") lines = append(lines, lastBoxStyle+labelStyle("Links:")) for i, linkLine := range linkLines { if i == linkCount-1 { linkLine = strings.Replace(linkLine, "├─", "└─", 1) } lines = append(lines, linkLine) } } } else { if len(lines) > 0 { lastIdx := len(lines) - 1 lines[lastIdx] = strings.Replace(lines[lastIdx], "├─", "└─", 1) } } if len(lines) > 0 { return strings.Join(lines, "\n") + "\n" } return "" }