-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
65 lines (61 loc) · 1.56 KB
/
main.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
60
61
62
63
64
65
package main
import (
"4zp6/cigo/pkg/commandParser"
"4zp6/cigo/pkg/commands"
"fmt"
"os"
"github.com/gookit/color"
"github.com/tcnksm/go-input"
)
func main() {
args, err := commandParser.Parse(os.Args[1:])
if err != nil {
os.Exit(1)
}
switch commandParser.GetCommand() {
case commandParser.LIST:
err := commands.List()
if err != nil {
fmt.Printf("Faced error while running List: %v\n", err)
}
case commandParser.SEARCH:
projs, err := commands.Search(args.Search.SearchItems)
if err != nil {
fmt.Printf("Faced error: %v\n", err)
return
}
for _, p := range projs {
fmt.Println(p.Name)
}
case commandParser.CREATESCHEMA:
err := commands.CreateSchema(args.CreateSchema.Type)
if err != nil {
fmt.Printf("Failed to create schema for %v: %v\n", args.CreateSchema.Type, err)
} else {
fmt.Printf("Created schema for %v\n", args.CreateSchema.Type)
}
case commandParser.RUN:
err := commands.Run(args.Run.Positional.Project, args.Run.Positional.Target, args.DryRun)
if err != nil {
fmt.Println(err)
}
case commandParser.GETCHANGES:
projs, err := commands.GetAffected(args.GetChanged.Positional.BaseRef, args.GetChanged.Positional.HeadRef)
if err != nil {
color.Errorln("Failed to get affected projects", err)
} else if len(projs) == 0 {
color.Infoln("No projects affected...")
} else {
color.Infoln("Affected projects:")
for _, p := range projs {
color.Infoln("\t", p)
}
}
case commandParser.ADDPROJECT:
ui := &input.UI{}
err := commands.AddProject(ui)
if err != nil {
fmt.Println(err)
}
}
}