config/config.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
package config import ( "log" "os" "strings" ) type Config struct { Processes []Process } type Process struct { Name string Clone string Ref string RunCmds []string } func ShittilyParseConfig(file string) Config { var conf Config data, err := os.ReadFile(file) if err != nil { log.Fatal(err) } // ty forest configPieces := strings.Split(string(data), "\n") var process Process for _, chunk := range configPieces { if chunk == "" { // write the process hunk if lolol // lmao wat this is awful if process.Name != "" { conf.Processes = append(conf.Processes, process) } continue } parts := strings.Split(chunk, "\"") if parts[0] == "process " { // we can assume the previous process is complete, so // if it exists, we add it to the broader array process = Process{} process.Name = parts[1] } else if parts[0] == " clone " { process.Clone = parts[1] } else if parts[0] == " ref " { process.Ref = parts[1] } else if parts[0] == " run " { process.RunCmds = append(process.RunCmds, parts[1]) } else { log.Fatal("idfk lol") } } // read file return conf }