Print out stdout of a game. Fixed a typo.
This commit is contained in:
parent
11f56b772e
commit
5efbc5a82c
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user