MCPcopy Create free account
hub / github.com/VirusTotal/vt-cli / Print

Method Print

utils/printer.go:50–71  ·  view source on GitHub ↗

Print prints the provided data to stdout.

(data interface{})

Source from the content-addressed store, hash-verified

48
49// Print prints the provided data to stdout.
50func (p *Printer) Print(data interface{}) error {
51 format := strings.ToLower(viper.GetString("format"))
52 if format == "" || format == "yaml" {
53 return yaml.NewEncoder(
54 ansi.NewAnsiStdout(),
55 yaml.EncoderColors(p.colors),
56 yaml.EncoderDateKeys([]glob.Glob{
57 glob.MustCompile("last_login"),
58 glob.MustCompile("user_since"),
59 glob.MustCompile("date"),
60 glob.MustCompile("*_date"),
61 })).Encode(data)
62 } else if format == "json" {
63 encoder := json.NewEncoder(ansi.NewAnsiStdout())
64 encoder.SetIndent("", " ")
65 return encoder.Encode(data)
66 } else if format == "csv" {
67 return csv.NewEncoder(ansi.NewAnsiStdout()).Encode(data)
68 } else {
69 return errors.New("unknown format")
70 }
71}
72
73// PrintSyncMap prints a sync.Map.
74func (p *Printer) PrintSyncMap(sm *sync.Map) error {

Callers 8

PrintSyncMapMethod · 0.95
PrintObjectsMethod · 0.95
PrintIteratorMethod · 0.95
NewRelationshipsCmdFunction · 0.95
NewIOCStreamDeleteCmdFunction · 0.80
NewInitCmdFunction · 0.80

Calls 5

EncodeMethod · 0.95
NewEncoderFunction · 0.92
EncoderColorsFunction · 0.92
EncoderDateKeysFunction · 0.92
NewEncoderFunction · 0.92

Tested by

no test coverage detected