diff --git a/config.go b/config.go index 1167408..395df2d 100644 --- a/config.go +++ b/config.go @@ -1,6 +1,7 @@ package main import ( + "bufio" "fmt" "github.com/BurntSushi/toml" "os" @@ -40,12 +41,11 @@ func setupConfig(rerun bool) (*Config, error) { _, statErr := os.Stat(cfgPath) 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):") - var s string - _, err = fmt.Scanln(&s) + s, err := readLine() if err != nil { return nil, fmt.Errorf("unable to read input: %v", err) } - newConfig.WowDir = strings.TrimSpace(s) + newConfig.WowDir = s 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): ")) @@ -146,3 +146,12 @@ func input(prompt string) (string, error) { } 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 +}