-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.go
61 lines (52 loc) · 1.47 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
package main
import (
_ "embed"
"fmt"
"github.com/spf13/cobra"
"magecomm/cmd"
"magecomm/config_manager"
"magecomm/logger"
"magecomm/notifictions"
"magecomm/services"
"os"
"strings"
)
//go:embed version.txt
var version string
var RootCmd = &cobra.Command{
Use: "magecomm",
Short: "MageComm CLI is a command line tool for managing Magento applications",
PersistentPreRun: func(cmd *cobra.Command, args []string) {
debug, _ := cmd.Flags().GetBool("debug")
if debug {
logger.EnableDebugMode()
}
overrideFilePath, _ := cmd.Flags().GetString("config")
config_manager.Configure(overrideFilePath)
initializeModuleWhichRequireConfig()
},
}
func initializeModuleWhichRequireConfig() {
notifictions.Initialize()
services.InitializeRMQ()
services.InitializeSQS()
}
func main() {
if len(os.Args) > 1 && os.Args[1] == "version" {
//Remove the release-please comment from the version output
version = strings.Split(version, "##")[0]
fmt.Printf("Magecomm Version: %s\n", strings.TrimSpace(version))
return
}
RootCmd.AddCommand(cmd.ListenCmd)
RootCmd.AddCommand(cmd.MagerunCmd)
RootCmd.AddCommand(cmd.CatCmd)
//RootCmd.AddCommand(cmd.CatDeployCmd)
//RootCmd.AddCommand(cmd.DeployCmd)
RootCmd.PersistentFlags().String("config", "", "Path to config file")
RootCmd.PersistentFlags().Bool("debug", false, "Enable debug mode")
err := RootCmd.Execute()
if err != nil {
logger.Fatalf("Failed to execute command: %s", strings.ReplaceAll(err.Error(), "\n", " "))
}
}