-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
133 lines (112 loc) · 4.13 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
package main
import (
"sync"
"wowtools/internal"
util "wowtools/internal/utilities"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
func main() {
// in the github actions, the version is set by the build script at
// build time and will be set via conventioanl commits
const version = "0.0.0"
var (
logging string
help bool
versionFlag bool
wtfzip string
wowversion string
addonname string
)
util.LoadConfig(".")
var rootCmd = &cobra.Command{
Use: "wowtools",
Long: "wowtools is a CLI tool for managing World of Warcraft file configurations.",
Run: func(cmd *cobra.Command, args []string) {
util.SetupLogger("info")
if versionFlag {
util.Log.Info("wowtools version: " + version)
}
},
}
var updateCmd = &cobra.Command{
Use: "update",
Short: "Update your Wowtools app to the latest version",
Run: func(cmd *cobra.Command, args []string) {
util.SetupLogger(logging)
internal.UpdateApp(version)
},
}
var backupCmd = &cobra.Command{
Use: "backup",
Short: "Backup your WTF folder",
Run: func(cmd *cobra.Command, args []string) {
util.SetupLogger(logging)
// WaitGroup for creating missing folders.
util.Log.Debug("Creating WaitGroup if folders are missing")
var wg sync.WaitGroup
wg.Add(2)
go util.VerifyFolders(viper.GetString("backup_dir"), &wg)
go util.VerifyFolders(viper.GetString("backup_dir")+"WTF", &wg)
wg.Wait()
util.Log.Debug("Beginning WtfBackup function")
internal.WtfBackup()
},
}
var wtfRestoreCmd = &cobra.Command{
Use: "wtfrestore",
Short: "Restore your WTF folder",
Run: func(cmd *cobra.Command, args []string) {
util.SetupLogger(logging)
if wtfzip == "" {
util.Log.Fatal("You must specify a WTF zip file to restore")
}
internal.WtfRestore(wtfzip)
},
}
var ptrCopyCmd = &cobra.Command{
Use: "ptrcopy",
Short: "Copy PTR data from Retail",
Run: func(cmd *cobra.Command, args []string) {
util.SetupLogger(logging)
internal.CopyPtrData()
},
}
var addonCopyCmd = &cobra.Command{
Use: "addoncopy",
Short: "Copy Addon data from Retail",
Run: func(cmd *cobra.Command, args []string) {
util.SetupLogger(logging)
internal.CopyAddonData(wowversion, addonname)
},
}
// updateCmd Flags
updateCmd.Flags().StringVarP(&logging, "logging", "l", "info", "Enables logging. Options are: trace, debug, info, warn, error, fatal, panic")
// backupCmd Flags
backupCmd.Flags().StringVarP(&logging, "logging", "l", "info", "Enables logging. Options are: trace, debug, info, warn, error, fatal, panic")
backupCmd.Flags().BoolVarP(&help, "help", "h", false, "Displays useful information")
// wtfRestore Flags
wtfRestoreCmd.Flags().StringVarP(&logging, "logging", "l", "info", "Enables logging. Options are: trace, debug, info, warn, error, fatal, panic")
wtfRestoreCmd.Flags().BoolVarP(&help, "help", "h", false, "Displays useful information")
wtfRestoreCmd.Flags().StringVarP(&wtfzip, "wtfzip", "w", "", "File name of WTF Zip")
// ptrCopyCmd Flags
ptrCopyCmd.Flags().StringVarP(&logging, "logging", "l", "info", "Enables logging. Options are: trace, debug, info, warn, error, fatal, panic")
ptrCopyCmd.Flags().BoolVarP(&help, "help", "h", false, "Displays useful information")
// addonCopyCmd Flags
addonCopyCmd.Flags().StringVarP(&logging, "logging", "l", "info", "Enables logging. Options are: trace, debug, info, warn, error, fatal, panic")
addonCopyCmd.Flags().BoolVarP(&help, "help", "h", false, "Displays useful information")
addonCopyCmd.Flags().StringVarP(&wowversion, "wowVersion", "w", "", "The version of WoW to copy the addon data to")
addonCopyCmd.Flags().StringVarP(&addonname, "addonName", "a", "", "The name of the addon to copy")
// rootCmd Flags
rootCmd.Flags().BoolVarP(&help, "help", "h", false, "Displays useful information")
rootCmd.Flags().BoolVarP(&versionFlag, "version", "v", false, "Displays the current version of wowtools")
// Add commands to rootCmd
rootCmd.AddCommand(updateCmd)
rootCmd.AddCommand(backupCmd)
rootCmd.AddCommand(wtfRestoreCmd)
rootCmd.AddCommand(ptrCopyCmd)
rootCmd.AddCommand(addonCopyCmd)
if err := rootCmd.Execute(); err != nil {
util.Log.Fatal(err)
}
}