magellan/internal/util/print.go
David Allen a6c445b86f
Add support for storage command and crawler output
Partially addresses issue #3 by adding a simple `magellan list devices` command to list storage devices. To close the issue, this PR still requires including storage device information in the `crawler`'s output.

Reviewed-on: towk/magellan-ng#5
2025-06-29 16:36:44 -06:00

25 lines
476 B
Go

package util
import (
"encoding/json"
"fmt"
"github.com/rs/zerolog/log"
"gopkg.in/yaml.v2"
)
func PrintJSON(data any) {
b, err := json.MarshalIndent(data, "", " ")
if err != nil {
log.Error().Err(err).Msgf("failed to marshal scanned results to JSON")
}
fmt.Println(string(b))
}
func PrintYAML(data any) {
b, err := yaml.Marshal(data)
if err != nil {
log.Error().Err(err).Msgf("failed to marshal scanned results to JSON")
}
fmt.Printf("%s\n", string(b))
}