forked from ForceCLI/force
-
Notifications
You must be signed in to change notification settings - Fork 0
/
trace.go
72 lines (61 loc) · 1.18 KB
/
trace.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package main
import (
"fmt"
)
var cmdTrace = &Command{
Run: runTrace,
Usage: "trace <command>",
Short: "Manage trace flags",
Long: `
Manage trace flags
Examples:
force trace start
force trace list
force trace delete <id>
`,
}
func init() {
}
func runTrace(cmd *Command, args []string) {
if len(args) == 0 {
cmd.printUsage()
return
}
switch args[0] {
case "list":
runQueryTrace()
case "start":
runStartTrace()
case "delete":
if len(args) != 2 {
ErrorAndExit("You need to provide the id of a TraceFlag to delete.")
}
runDeleteTrace(args[1])
default:
ErrorAndExit("no such command: %s", args[0])
}
}
func runQueryTrace() {
force, _ := ActiveForce()
result, err := force.QueryTraceFlags()
if err != nil {
ErrorAndExit(err.Error())
}
DisplayForceRecordsf(result.Records, "json-pretty")
}
func runStartTrace() {
force, _ := ActiveForce()
_, err, _ := force.StartTrace()
if err != nil {
ErrorAndExit(err.Error())
}
fmt.Printf("Tracing Enabled\n")
}
func runDeleteTrace(id string) {
force, _ := ActiveForce()
err := force.DeleteToolingRecord("TraceFlag", id)
if err != nil {
ErrorAndExit(err.Error())
}
fmt.Printf("Trace Flag deleted\n")
}