fix spacing

This commit is contained in:
2025-07-12 05:28:34 -07:00
parent 2cb2208478
commit afb8457489

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"
@ -40,12 +41,11 @@ func setupConfig(rerun bool) (*Config, error) {
_, statErr := os.Stat(cfgPath) _, statErr := os.Stat(cfgPath)
if rerun || os.IsNotExist(statErr) { if rerun || os.IsNotExist(statErr) {
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): "))
@ -115,14 +115,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
@ -146,3 +144,12 @@ func input(prompt string) (string, error) {
} }
return strings.TrimSpace(s), nil return strings.TrimSpace(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
}