-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
73 lines (57 loc) · 1.2 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
66
67
68
69
70
71
72
73
package main
import (
"fmt"
"os"
"github.com/lassejlv/action/utils"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
)
func main() {
// Enable pretty logging
log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stdout})
commands := utils.ParseCommands()
// Run the first command if no command is specified
if len(os.Args) < 2 && len(commands) > 0 {
utils.RunCmd(commands[0].String, true)
return
}
cmdToRun := os.Args[1]
if cmdToRun == "--list" {
utils.PrintAvailableCommands(cmdToRun)
return
}
if cmdToRun == "--version" {
fmt.Println(utils.CurrentVersion)
return
}
if cmdToRun == "--upgrade" {
utils.Upgrade()
return
}
if cmdToRun == "--init" {
log.Info().Msg("Not implemented yet")
return
}
if cmdToRun == "--help" {
utils.Help()
return
}
if cmdToRun == "--all" {
utils.RunAll()
return
}
for _, command := range commands {
if command.Name == cmdToRun {
config, err := utils.HasConfig(command.String)
if err != nil {
log.Error().Msgf("Error parsing config: %s", err)
return
} else {
fmt.Print(config)
}
utils.RunCmd(command.String, true)
return
}
}
log.Error().Msgf("Command '%s' not found in config", cmdToRun)
}