add comment
This commit is contained in:
parent
4a4c8669df
commit
177ba91d51
1 changed files with 4 additions and 1 deletions
|
@ -9,7 +9,10 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// REPL runs a read-evaluate-print-loop. Commands are taken from src and output
|
||||||
|
// is written to dst. assets is needed for commands like reload.
|
||||||
func (g *Game) REPL(src io.Reader, dst io.Writer, assets fs.FS) error {
|
func (g *Game) REPL(src io.Reader, dst io.Writer, assets fs.FS) error {
|
||||||
|
fmt.Fprint(dst, "game>")
|
||||||
sc := bufio.NewScanner(src)
|
sc := bufio.NewScanner(src)
|
||||||
for sc.Scan() {
|
for sc.Scan() {
|
||||||
tok := strings.Split(sc.Text(), " ")
|
tok := strings.Split(sc.Text(), " ")
|
||||||
|
@ -53,7 +56,6 @@ func (g *Game) REPL(src io.Reader, dst io.Writer, assets fs.FS) error {
|
||||||
g.Enable()
|
g.Enable()
|
||||||
g.Show()
|
g.Show()
|
||||||
case "tree":
|
case "tree":
|
||||||
|
|
||||||
var c interface{} = g
|
var c interface{} = g
|
||||||
if len(tok) == 2 {
|
if len(tok) == 2 {
|
||||||
// subtree
|
// subtree
|
||||||
|
@ -93,6 +95,7 @@ func (g *Game) REPL(src io.Reader, dst io.Writer, assets fs.FS) error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
fmt.Fprint(dst, "game>")
|
||||||
}
|
}
|
||||||
return sc.Err()
|
return sc.Err()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue