forked from ForceCLI/force
-
Notifications
You must be signed in to change notification settings - Fork 0
/
apex.go
59 lines (51 loc) · 1.05 KB
/
apex.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
package main
import (
"fmt"
"io/ioutil"
"os"
)
var cmdApex = &Command{
Run: runApex,
Usage: "apex [file]",
Short: "Execute anonymous Apex code",
Long: `
Execute anonymous Apex code
Examples:
force apex ~/test.apex
force apex
>> Start typing Apex code; press CTRL-D when finished
`,
}
func init() {
}
func runApex(cmd *Command, args []string) {
var code []byte
var err error
if len(args) == 1 {
code, err = ioutil.ReadFile(args[0])
} else if len(args) > 1 {
fmt.Println("Got test indication.")
} else {
fmt.Println(">> Start typing Apex code; press CTRL-D when finished")
code, err = ioutil.ReadAll(os.Stdin)
fmt.Println("\n\n>> Executing code...")
}
if err != nil {
ErrorAndExit(err.Error())
}
force, _ := ActiveForce()
if len(args) <= 1 {
output, err := force.Partner.ExecuteAnonymous(string(code))
if err != nil {
ErrorAndExit(err.Error())
}
fmt.Println(output)
} else {
apexclass := args[1]
fmt.Println(apexclass)
err := force.GetCodeCoverage("", apexclass)
if err != nil {
ErrorAndExit(err.Error())
}
}
}