-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.go
More file actions
80 lines (69 loc) · 1.57 KB
/
Copy pathsetup.go
File metadata and controls
80 lines (69 loc) · 1.57 KB
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
73
74
75
76
77
78
79
80
package main
import (
"encoding/json"
"github.com/ashdawson/gomob/notif"
"io/ioutil"
"os"
)
var argsMap = map[string]string{}
var mobSettingsFile = "mobSettings.json"
var settings Settings
type Settings struct {
BaseBranchName string `json:"BaseBranchName"`
BaseRemoteName string `json:"BaseRemoteName"`
BranchName string `json:"BranchName"`
RemoteName string `json:"RemoteName"`
CommitMessage string `json:"CommitMessage"`
IDE string `json:"IDE"`
Mob string `json:"Mob"`
TimeLimit int
}
func setup() {
runChecks()
checkSettings()
readCommandLineArguments()
}
func createSettings() {
_, err := os.Create(mobSettingsFile)
check(err)
remoteName, branchName := getBranchDetails()
getIDE, _ := notif.List("Please select your IDE", []string{"phpstorm", "vscode"})
settings = Settings{
"master",
"origin",
branchName,
remoteName,
"WIP - [MOB] ",
getIDE,
"",
15,
}
saveSettings()
}
func saveSettings() {
file, _ := json.MarshalIndent(settings, "", " ")
err := ioutil.WriteFile(mobSettingsFile, file, 0644)
check(err)
}
func checkSettings() {
file, err := os.Open(mobSettingsFile)
file.Close()
if err != nil {
createSettings()
} else {
readSettings()
}
}
func readSettings() {
file, _ := ioutil.ReadFile(mobSettingsFile)
settings = Settings{}
err := json.Unmarshal([]byte(file), &settings)
check(err)
}
func (settings *Settings) updateSetting(setting string, value string) {
saveSettings()
}
func runChecks() {
_, err := os.Open(".git/info/exclude")
checkSay(err, "git has not been added to this directory")
}