mirror of
https://github.com/davidallendj/magellan.git
synced 2025-12-20 03:27:03 -07:00
Renamed vars and switched to use zerolog
This commit is contained in:
parent
606a7b47cc
commit
b27e6b6a73
7 changed files with 68 additions and 103 deletions
10
cmd/list.go
10
cmd/list.go
|
|
@ -7,6 +7,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/OpenCHAMI/magellan/internal/db/sqlite"
|
||||
"github.com/rs/zerolog/log"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/spf13/cobra"
|
||||
|
|
@ -24,16 +25,19 @@ var listCmd = &cobra.Command{
|
|||
" magellan list\n" +
|
||||
" magellan list --cache ./assets.db",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
probeResults, err := sqlite.GetProbeResults(cachePath)
|
||||
scannedResults, err := sqlite.GetScannedResults(cachePath)
|
||||
if err != nil {
|
||||
logrus.Errorf("failed toget probe results: %v\n", err)
|
||||
}
|
||||
format = strings.ToLower(format)
|
||||
if format == "json" {
|
||||
b, _ := json.Marshal(probeResults)
|
||||
b, err := json.Marshal(scannedResults)
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msgf("failed to unmarshal scanned results")
|
||||
}
|
||||
fmt.Printf("%s\n", string(b))
|
||||
} else {
|
||||
for _, r := range probeResults {
|
||||
for _, r := range scannedResults {
|
||||
fmt.Printf("%s:%d (%s) @ %s\n", r.Host, r.Port, r.Protocol, r.Timestamp.Format(time.UnixDate))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue