repl: add status,help,host cmds

and don't re-apply task for local commands
This commit is contained in:
Norwin 2022-01-02 06:46:53 +01:00
parent 4e0cc35c26
commit 48f1fce93d
1 changed files with 19 additions and 9 deletions

View File

@ -86,7 +86,7 @@ func RunREPL(f Fluter) {
} }
} }
case "address", "a": case "host", "address", "a":
if len(args) == 1 { if len(args) == 1 {
t.Address = args[0] t.Address = args[0]
} }
@ -131,14 +131,24 @@ func RunREPL(f Fluter) {
} }
} }
// the commands below don't affect the task, so we don't need to apply it to clients -> continue
case "metrics": case "metrics":
f.toggleMetrics() f.toggleMetrics()
printTask = false continue
case "status":
fmt.Println(t)
continue
case "help":
printHelp()
continue
default: default:
printTask = false
fmt.Print("[rán] unknown command. ") fmt.Print("[rán] unknown command. ")
printHelp() printHelp()
continue
} }
if printTask { if printTask {
@ -151,18 +161,18 @@ func RunREPL(f Fluter) {
func printHelp() { func printHelp() {
fmt.Println(`available commands: fmt.Println(`available commands:
start start fluting start start fluting
stop pause fluting stop pause fluting
c <n> set number of connections per client c <n> set number of connections per client
a <host>:<port> set target server a <host>:<port> set target server
offset <x> <y> set top-left offset offset <x> <y> set top-left offset
offset rand random offset for each draw offset rand random offset for each draw
metrics toggle bandwidth reporting (may cost some performance) metrics toggle bandwidth reporting (may cost some performance)
i <filepath> set image i <filepath> set image
txt <scale> <color <bgcolor> <txt> send text txt <scale> <color <bgcolor> <txt> send text
txt [<scale> [<color> [<bgcolor>]] enter interactive text mode txt [<scale> [<color> [<bgcolor>]] enter interactive text mode
rgbsplit toggle RGB split effect rgbsplit toggle RGB split effect
o set order (l,r,t,b,shuffle)`) o set order (l,r,t,b,shuffle)`)
} }