-
Notifications
You must be signed in to change notification settings - Fork 0
/
switch-latest.go
47 lines (38 loc) · 1.14 KB
/
switch-latest.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 command
import (
"github.com/S-Shimotori/ninjin/model"
"github.com/S-Shimotori/ninjin/function"
"strings"
"fmt"
)
type SwitchLatestCommand struct {
Meta
}
func (c *SwitchLatestCommand) Run(args []string) int {
xcodeList, xcodeError := function.GetXcodeList(function.ApplicationsPath)
if xcodeError != nil {
fmt.Printf(FailInMakingAListOfXcodes)
return 1
}
if len(xcodeList) == 0 {
fmt.Printf(FailInFindingXcodeLatest)
return 1
}
xcode := xcodeList[len(xcodeList) - 1]
_, execError := function.ExecXcodeSelectSwitchOutput(xcode.AppPath + function.PathToDeveloperDirectoryPath)
if execError == nil {
fmt.Printf(SucceedInSwitching, model.GetShortVersionInString(xcode.Version.Short), model.GetProductBuildVersionInString(xcode.Version.ProductBuild))
return 0
} else {
fmt.Printf(FailInSwitching, model.GetShortVersionInString(xcode.Version.Short) + " " + model.GetProductBuildVersionInString(xcode.Version.ProductBuild))
return 1
}
}
func (c *SwitchLatestCommand) Synopsis() string {
return "switch Xcode (latest version)"
}
func (c *SwitchLatestCommand) Help() string {
helpText := `
`
return strings.TrimSpace(helpText)
}