summaryrefslogtreecommitdiffstats
path: root/internal/formatter/bssid.go
blob: 06aa3cc513f78ce768dd57331055f8c4c13ba332 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package formatter

import (
	"fmt"

	"git.db.org.ai/dborg/internal/models"
	"git.db.org.ai/dborg/internal/utils"
)

func FormatBSSIDResults(response models.BSSIDLookupResponse, asJSON bool) error {
	if asJSON {
		return utils.PrintJSON(response)
	}

	if len(response) == 0 {
		PrintWarning("No results found")
		return nil
	}

	PrintSection("BSSID Lookup Results")

	for i, result := range response {
		if i > 0 {
			PrintDivider()
		}

		fmt.Printf("\n%s: %s\n", Cyan("BSSID"), Bold(result.BSSID))

		if result.Location != nil {
			fmt.Printf("%s: %s\n", Cyan("Latitude"), Yellow(fmt.Sprintf("%.6f", result.Location.Latitude)))
			fmt.Printf("%s: %s\n", Cyan("Longitude"), Yellow(fmt.Sprintf("%.6f", result.Location.Longitude)))
			fmt.Printf("%s: %s\n", Cyan("Accuracy"), Dim(fmt.Sprintf("%d meters", result.Location.Accuracy)))

			if result.GoogleMap != "" {
				fmt.Printf("%s: %s\n", Cyan("Google Maps"), result.GoogleMap)
			}
			if result.OpenStreetMap != "" {
				fmt.Printf("%s: %s\n", Cyan("OpenStreetMap"), result.OpenStreetMap)
			}
		} else {
			fmt.Printf("%s\n", Gray("No location data available"))
		}
	}

	fmt.Println()
	return nil
}