From 027a8e073bb946f990881874703c044cae25ffe5 Mon Sep 17 00:00:00 2001 From: Evan Burkey Date: Thu, 5 Jun 2025 11:32:02 -0700 Subject: [PATCH] error handling, release builds --- .gitignore | 5 +++-- README.md | 15 +++++++-------- main.go | 30 ++++++++++++++++++++---------- release.sh | 19 +++++++++++++++++-- 4 files changed, 47 insertions(+), 22 deletions(-) diff --git a/.gitignore b/.gitignore index 37e8f53..8d9f9bf 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .idea -epoch-linux -epoch-linux.tar.gz +bin/ +epochcli-* +*.tar.gz diff --git a/README.md b/README.md index 5c3ddd6..01614cb 100644 --- a/README.md +++ b/README.md @@ -1,23 +1,22 @@ -# epoch-linux +# epochcli -Linux updater and launcher for [Project Epoch](https://www.project-epoch.net/) Still a work in progress. +CLI tool for updating and launching [Project Epoch](https://www.project-epoch.net/) on Linux & macOS. ## TODO -- better error handling - improve config generation - add ability to launch Epoch after an update - +- Properly test on macOS ## Instructions 1. Set up a copy of WoW 3.3.5 in a wine prefix or launcher of your choice. Chromiecraft has a good torrent you can use for the 3.3.5 client -2. Install `epoch-linux` by either +2. Install `epochcli` by either 1. Download the latest binary from the [releases](https://git.burkey.co/eburk/epoch-linux/releases) page - 2. If you have the `go` toolchain installed, you can run `go install git.burkey.co/eburk/epoch-linux` to install to your `$GOROOT` + 2. If you have the `go` toolchain installed, you can run `go install git.burkey.co/eburk/epochcli` to install to your `$GOROOT` 3. Compile the source yourself -3. Run `epoch-linux` once. This will create a config file at `$HOME/.config/epoch-linux/config.toml`. Change the `WowDir` variable to your Wow game directory -4. Run `epoch-linux` again. It will download the patch files from Epoch's servers to your Wow directory +3. Run `epochcli` once. This will create a config file at `$HOME/.config/epoch-linux/config.toml`. Change the `WowDir` variable to your Wow game directory +4. Run `epochcli` again. It will download the patch files from Epoch's servers to your Wow directory 5. Use your launcher or tool of choice to startup Epoch in `wine` ## Issues diff --git a/main.go b/main.go index 5b47a0c..8a04b3a 100644 --- a/main.go +++ b/main.go @@ -14,9 +14,10 @@ import ( ) const ( - manifestUrl = "https://updater.project-epoch.net/api/manifest" - configDirName = "epoch-linux" - configName = "config.toml" + manifestUrl = "https://updater.project-epoch.net/api/manifest" + defaultWowPath = "/path/to/wow" + configDirName = "epoch-linux" + configName = "config.toml" ) type Config struct { @@ -27,10 +28,10 @@ var ( config Config ) -func setupConfig() { +func setupConfig() error { home := os.Getenv("HOME") if home == "" { - log.Fatal("$HOME environment variable not set") + return fmt.Errorf("$HOME environment variable not set") } cfgPath := filepath.Join(home, ".config", configDirName, configName) @@ -39,18 +40,18 @@ func setupConfig() { os.MkdirAll(filepath.Join(home, ".config", configDirName), 0755) newConfig := &Config{ - WowDir: "/path/to/wow", + WowDir: defaultWowPath, } file, err := os.Create(cfgPath) if err != nil { - log.Fatal(err) + return err } defer file.Close() encoder := toml.NewEncoder(file) if err = encoder.Encode(newConfig); err != nil { - log.Fatal(err) + return err } fmt.Printf("Created new config at %s, edit it before running the launcher again\n", cfgPath) @@ -59,12 +60,21 @@ func setupConfig() { _, err := toml.DecodeFile(cfgPath, &config) if err != nil { - log.Fatal(err) + return err } + + if config.WowDir == defaultWowPath { + return fmt.Errorf("WowDir in %s is still the default setting", cfgPath) + } + + return nil } func main() { - setupConfig() + err := setupConfig() + if err != nil { + log.Fatal(err) + } count, err := downloadUpdate() if err != nil { diff --git a/release.sh b/release.sh index 3c72f61..9e96234 100755 --- a/release.sh +++ b/release.sh @@ -2,5 +2,20 @@ set -e -GOOS=linux GOARCH=amd64 go build -tar czvf epoch-linux.tar.gz ./epoch-linux +rm ./*.tar.gz + +mkdir bin + +GOOS=linux GOARCH=amd64 go build -o bin/epochcli-linux-amd64 +tar czvf epochcli-linux-amd64.tar.gz bin/epochcli-linux-amd64 + +GOOS=linux GOARCH=arm64 go build -o bin/epochcli-linux-arm64 +tar czvf epochcli-linux-arm64.tar.gz bin/epochcli-linux-arm64 + +GOOS=darwin GOARCH=amd64 go build -o bin/epochcli-darwin-amd64 +tar czvf epochcli-darwin-amd64.tar.gz bin/epochcli-darwin-amd64 + +GOOS=darwin GOARCH=arm64 go build -o bin/epochcli-darwin-arm64 +tar czvf epochcli-darwin-arm64.tar.gz bin/epochcli-darwin-arm64 + +rm -rf bin \ No newline at end of file