3 Commits
1.0.6 ... 1.0.7

Author SHA1 Message Date
882413fb1e 1.0.7 2025-07-12 05:51:33 -07:00
2cdeeef5b4 fix mac issues 2025-07-12 05:51:07 -07:00
afb8457489 fix spacing 2025-07-12 05:29:58 -07:00
3 changed files with 27 additions and 16 deletions

View File

@ -1,6 +1,7 @@
package main package main
import ( import (
"bufio"
"fmt" "fmt"
"github.com/BurntSushi/toml" "github.com/BurntSushi/toml"
"os" "os"
@ -22,7 +23,10 @@ const (
configName = "config.toml" configName = "config.toml"
) )
var cfgPath string var (
configRun = false
cfgPath string
)
func setupConfig(rerun bool) (*Config, error) { func setupConfig(rerun bool) (*Config, error) {
home, err := os.UserHomeDir() home, err := os.UserHomeDir()
@ -39,13 +43,13 @@ func setupConfig(rerun bool) (*Config, error) {
_, statErr := os.Stat(cfgPath) _, statErr := os.Stat(cfgPath)
if rerun || os.IsNotExist(statErr) { if rerun || os.IsNotExist(statErr) {
configRun = true
fmt.Println("Enter the path to your Wow directory below. Use the full path without shortcuts like '~' (ex: /home/user/epoch):") fmt.Println("Enter the path to your Wow directory below. Use the full path without shortcuts like '~' (ex: /home/user/epoch):")
var s string s, err := readLine()
_, err = fmt.Scanln(&s)
if err != nil { if err != nil {
return nil, fmt.Errorf("unable to read input: %v", err) return nil, fmt.Errorf("unable to read input: %v", err)
} }
newConfig.WowDir = strings.TrimSpace(s) newConfig.WowDir = s
fmt.Println() fmt.Println()
p, err := promptYesNo(fmt.Sprintf("Do you want to use epochcli to launch Wow? Select No if you plan on using a launcher tool like Lutris (y/n): ")) p, err := promptYesNo(fmt.Sprintf("Do you want to use epochcli to launch Wow? Select No if you plan on using a launcher tool like Lutris (y/n): "))
@ -81,7 +85,7 @@ func setupConfig(rerun bool) (*Config, error) {
if s == "" { if s == "" {
fmt.Printf("wine %s\n", newConfig.LaunchCmd) fmt.Printf("wine %s\n", newConfig.LaunchCmd)
} else { } else {
fmt.Printf("WINEPREFIX=%s wine %s\n", newConfig.WinePrefix, newConfig.LaunchCmd) fmt.Printf("WINEPREFIX=%s %s\n", newConfig.WinePrefix, newConfig.LaunchCmd)
} }
fmt.Printf("Modify the configuration file at %s if you need to customize it\n\n", cfgPath) fmt.Printf("Modify the configuration file at %s if you need to customize it\n\n", cfgPath)
} }
@ -115,14 +119,12 @@ func setupConfig(rerun bool) (*Config, error) {
} }
func promptYesNo(prompt string) (bool, error) { func promptYesNo(prompt string) (bool, error) {
var s string
for { for {
fmt.Print(prompt) fmt.Print(prompt)
_, err := fmt.Scanf("%s", &s) s, err := readLine()
if err != nil { if err != nil {
return false, fmt.Errorf("unable to read input: %v", err) return false, fmt.Errorf("unable to read input: %v", err)
} }
s := strings.TrimSpace(s)
if s == "y" || s == "Y" { if s == "y" || s == "Y" {
return true, nil return true, nil
@ -139,10 +141,18 @@ func input(prompt string) (string, error) {
fmt.Println(prompt) fmt.Println(prompt)
fmt.Printf("> ") fmt.Printf("> ")
var s string s, err := readLine()
_, err := fmt.Scanf("%s", &s)
if err != nil { if err != nil {
return "", fmt.Errorf("unable to read input: %v", err) return "", fmt.Errorf("unable to read input: %v", err)
} }
return strings.TrimSpace(s), nil return s, nil
}
func readLine() (string, error) {
reader := bufio.NewReader(os.Stdin)
in, err := reader.ReadString('\n')
if err != nil {
return "", fmt.Errorf("unable to read input: %v", err)
}
return strings.TrimSpace(in), nil
} }

View File

@ -11,7 +11,6 @@ import (
"os" "os"
"os/exec" "os/exec"
"path/filepath" "path/filepath"
"runtime"
"strings" "strings"
) )
@ -70,6 +69,11 @@ func main() {
fmt.Printf("%d files are already up to date\n\n", stats.current) fmt.Printf("%d files are already up to date\n\n", stats.current)
} }
if configRun {
fmt.Println("Configuration complete!")
os.Exit(0)
}
if updateOnlyFlag { if updateOnlyFlag {
os.Exit(0) os.Exit(0)
} }
@ -81,9 +85,6 @@ func main() {
fmt.Println("Starting Epoch...") fmt.Println("Starting Epoch...")
var cmd = strings.Split(config.LaunchCmd, " ") var cmd = strings.Split(config.LaunchCmd, " ")
if runtime.GOOS == "darwin" {
cmd = append([]string{"open"}, cmd...)
}
ex := exec.Command(cmd[0], cmd[1:]...) ex := exec.Command(cmd[0], cmd[1:]...)
cmdStr := strings.Join(cmd, " ") cmdStr := strings.Join(cmd, " ")
if config.WinePrefix != "" { if config.WinePrefix != "" {

View File

@ -7,7 +7,7 @@ import (
"regexp" "regexp"
) )
const version = "1.0.6" const version = "1.0.7"
const versionUrl = "https://git.burkey.co/eburk/epochcli/raw/branch/master/version.go" const versionUrl = "https://git.burkey.co/eburk/epochcli/raw/branch/master/version.go"
func needUpdate() (bool, error) { func needUpdate() (bool, error) {