Print out stdout of a game. Fixed a typo.

This commit is contained in:
Alexander Andreev 2023-11-19 02:10:56 +04:00
parent 11f56b772e
commit 5efbc5a82c
Signed by: Arav
GPG Key ID: D22A817D95815393

View File

@ -1,6 +1,7 @@
package commands
import (
"bufio"
"errors"
"fmt"
"mccl/internal/manifest"
@ -139,21 +140,21 @@ func (rc *RunCommand) run_client() error {
}
cmd := exec.Command(path.Join(javaHome, "bin", "java"), cl...)
// stdout, err := cmd.StdoutPipe()
// cmd.Stderr = cmd.Stdout
// if err != nil {
// return err
// }
// defer stdout.Close()
stdout, err := cmd.StdoutPipe()
cmd.Stderr = cmd.Stdout
if err != nil {
return err
}
defer stdout.Close()
// scanner := bufio.NewScanner(stdout)
// go func() {
// for scanner.Scan() {
// fmt.Println(scanner.Text())
// }
// }()
scanner := bufio.NewScanner(stdout)
go func() {
for scanner.Scan() {
fmt.Println(scanner.Text())
}
}()
fmt.Printf("Minecraft version %s is started with usename %s and player's UUID %s.\n",
fmt.Printf("Minecraft version %s is started with username %s and player's UUID %s.\n",
manifst.Id, rc.Username, rc.AuthUuid)
if err := cmd.Run(); err != nil && (err.Error() != "exec: already started") {
return err