forked from ForceCLI/force
-
Notifications
You must be signed in to change notification settings - Fork 0
/
logout.go
47 lines (40 loc) · 838 Bytes
/
logout.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
package main
import (
"fmt"
"os/exec"
"runtime"
)
var cmdLogout = &Command{
Usage: "logout",
Short: "Log out from force.com",
Long: `
force logout -u=username
Example:
force logout -u=user@example.org
`,
}
func init() {
cmdLogout.Run = runLogout
}
var (
userName1 = cmdLogout.Flag.String("u", "", "Username for Soap Login")
)
func runLogout(cmd *Command, args []string) {
if *userName1 == "" {
fmt.Println("Missing required argument...")
cmd.Flag.Usage()
return
}
Config.Delete("accounts", *userName1)
if active, _ := Config.Load("current", "account"); active == *userName1 {
Config.Delete("current", "account")
SetActiveLoginDefault()
}
if runtime.GOOS == "windows" {
cmd := exec.Command("title", account)
cmd.Run()
} else {
title := fmt.Sprintf("\033];%s\007", "")
fmt.Printf(title)
}
}