From c4c7837f00c117458c7680c91d79ad4da7970d98 Mon Sep 17 00:00:00 2001 From: ldougbmx <77259260+ldougbmx@users.noreply.github.com> Date: Sun, 9 Jan 2022 22:25:43 -0500 Subject: [PATCH] Feature/curseforge open (#7) * Add go concurrency to VerifyFolders, add OpenCurseforge * Add curseforge items * Add curseforge open function and test * Update readme --- README.md | 4 ++++ main.go | 5 +++-- test/startCurseforge_test.go | 21 +++++++++++++++++++++ utilities/curseforgeOpener.go | 25 +++++++++++++++++++++++++ wowtools-cli.yml | 4 +++- 5 files changed, 56 insertions(+), 3 deletions(-) create mode 100644 test/startCurseforge_test.go create mode 100644 utilities/curseforgeOpener.go diff --git a/README.md b/README.md index abe7e56..fa71b85 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,9 @@ The latest release can be found here: https://github.com/ldougbmx/wowtools/relea * The README and LICENSE files are also included in the release * Place the files anywhere on your system (but both in the same directory) * Verify/Update the wowtools-cli.yml to set custom paths if needed + * The curseforge_args will need to be filled out for Curseforge to open. If they are not, only the full full Overwolf app will open. + * These can be grabbed from the Curseforge exe by right-clicking and selecting Properties. + * Copy the target -launchapp xxxxxxxxxxxxxxxxx -from-startmenu section and insert it into the yml. * Run wowtools.exe ## Usage @@ -24,6 +27,7 @@ Update the wowtools-cli.yml file if you have WoW installed in a custom location. 2. Deletes current ElvUI install in the Addons directory 3. Downloads latest zip of ElvUI 4. Unzips and moves folder to your Addons directory +4. Asks user if they want to open the Curseforge application ## Planned enhancements * Implement CLI commands to allow users to perform specific actions on demand. diff --git a/main.go b/main.go index 76cf85d..cf688af 100644 --- a/main.go +++ b/main.go @@ -10,8 +10,9 @@ import ( func main() { cmd.InitConfig() utilities.VerifyFolders(viper.GetString("backup_dir")) - utilities.VerifyFolders(viper.GetString("backup_dir") + "ElvUI") - utilities.VerifyFolders(viper.GetString("backup_dir") + "WTF") + go utilities.VerifyFolders(viper.GetString("backup_dir") + "ElvUI") + go utilities.VerifyFolders(viper.GetString("backup_dir") + "WTF") cmd.WtfBackup() cmd.UpdateElvUI() + utilities.OpenCurseforge() } diff --git a/test/startCurseforge_test.go b/test/startCurseforge_test.go new file mode 100644 index 0000000..634f827 --- /dev/null +++ b/test/startCurseforge_test.go @@ -0,0 +1,21 @@ +package test + +import ( + "fmt" + "os/exec" + "testing" + + "github.com/spf13/viper" +) + +func TestCurseforgeOpener(t *testing.T) { + curseforgeExe := viper.GetString("curseforge_exe") + curseforgeArgs := viper.GetString("curseforge_args") + + fmt.Println("Opening Cureseforge") + cmd := exec.Command("powershell", "Start-Process", + fmt.Sprintf("-Filepath '%s'", curseforgeExe), + fmt.Sprintf("-ArgumentList '%s'", curseforgeArgs), + ) + fmt.Println(cmd.String()) +} diff --git a/utilities/curseforgeOpener.go b/utilities/curseforgeOpener.go new file mode 100644 index 0000000..6687ef9 --- /dev/null +++ b/utilities/curseforgeOpener.go @@ -0,0 +1,25 @@ +package utilities + +import ( + "fmt" + "log" + "os/exec" + + "github.com/spf13/viper" +) + +func OpenCurseforge() { + curseforgeExe := viper.GetString("curseforge_exe") + curseforgeArgs := viper.GetString("curseforge_args") + updatePrompt := AskForConfirmation("Do you want to launch Curseforge to update addons?") + if updatePrompt { + fmt.Println("Opening Cureseforge") + cmd := exec.Command("powershell", "Start-Process", + fmt.Sprintf("-Filepath '%s'", curseforgeExe), + fmt.Sprintf("-ArgumentList '%s'", curseforgeArgs)) + err := cmd.Start() + if err != nil { + log.Fatal(err) + } + } +} diff --git a/wowtools-cli.yml b/wowtools-cli.yml index 98fb84f..d497329 100644 --- a/wowtools-cli.yml +++ b/wowtools-cli.yml @@ -2,4 +2,6 @@ wtf_dir: "C:\\Program Files (x86)\\World of Warcraft\\_retail_\\WTF" backup_dir: "C:\\Program Files (x86)\\World of Warcraft\\_retail_\\Backups\\" elvui_dir: "C:\\Program Files (x86)\\World of Warcraft\\_retail_\\Interface\\AddOns\\ElvUI\\" elvui_options_dir: "C:\\Program Files (x86)\\World of Warcraft\\_retail_\\Interface\\AddOns\\ElvUI_OptionsUI\\" -addons_dir: "C:\\Program Files (x86)\\World of Warcraft\\_retail_\\Interface\\AddOns" \ No newline at end of file +addons_dir: "C:\\Program Files (x86)\\World of Warcraft\\_retail_\\Interface\\AddOns" +curseforge_exe: "C:\\Program Files (x86)\\Overwolf\\OverwolfLauncher.exe" +curseforge_args: "-launchapp xxxxxxxxxxxxxxxxxxxxxxxxxx -from-startmenu" \ No newline at end of file