forked from Telmate/proxmox-api-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprint.go
39 lines (31 loc) · 958 Bytes
/
print.go
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
package cli
import (
"encoding/json"
"fmt"
"io"
)
func PrintGuestStatus(out io.Writer, id int, text string) {
fmt.Fprintf(out, "Guest with id (%d) has been %s\n", id, text)
}
func PrintItemCreated(out io.Writer, id, text string) {
fmt.Fprintf(out, "%s (%s) has been created\n", text, id)
}
func PrintItemUpdated(out io.Writer, id, text string) {
fmt.Fprintf(out, "%s (%s) has been updated\n", text, id)
}
func PrintItemDeleted(out io.Writer, id, text string) {
fmt.Fprintf(out, "%s (%s) has been deleted\n", text, id)
}
func PrintItemSet(out io.Writer, id, text string) {
fmt.Fprintf(out, "%s (%s) has been configured\n", text, id)
}
func PrintRawJson(out io.Writer, input interface{}) {
list, err := json.Marshal(input)
LogFatalError(err)
fmt.Fprintln(out, string(list))
}
func PrintFormattedJson(out io.Writer, input interface{}) {
list, err := json.MarshalIndent(input, "", " ")
LogFatalError(err)
fmt.Fprintln(out, string(list))
}