MCPcopy Create free account
hub / github.com/ZeppelinMC/Zeppelin / StartConsole

Function StartConsole

util/console/console.go:38–67  ·  view source on GitHub ↗
(srv *server.Server)

Source from the content-addressed store, hash-verified

36}
37
38func StartConsole(srv *server.Server) {
39 var line string
40 var scanner = bufio.NewScanner(os.Stdin)
41
42 interrupt := make(chan os.Signal, 1)
43 signal.Notify(interrupt, os.Interrupt, os.Kill)
44
45 go func() {
46 for range interrupt {
47 newText := "\r> stop"
48 fmt.Print(newText)
49 l := len(line) + 3 // the addtitional 3 chars are "\r> "
50 if l > len(newText) {
51 fmt.Print(strings.Repeat(" ", l-len(newText)))
52 }
53 fmt.Println()
54 srv.Stop()
55 os.Stdin.Close()
56 }
57 }()
58
59 for {
60 if !scanner.Scan() {
61 break
62 }
63 line = scanner.Text()
64 srv.CommandManager.Call(line, Console)
65 fmt.Print("\r> ")
66 }
67}
68
69func StartRawConsole(srv *server.Server) {
70 var char [1]byte

Callers 1

mainFunction · 0.92

Calls 3

StopMethod · 0.80
CallMethod · 0.80
CloseMethod · 0.45

Tested by

no test coverage detected