print usage message if not in interactive mode, and no rcon commands passed

This commit is contained in:
onyx-and-iris 2024-11-04 21:23:45 +00:00
parent 05ee3f1912
commit f2752f5609

View File

@ -2,6 +2,7 @@ package main
import (
"bufio"
"errors"
"flag"
"fmt"
"io"
@ -16,6 +17,12 @@ import (
var interactive bool
func exit(err error) {
_, _ = fmt.Fprintf(os.Stderr, "Error: %s\n", err)
flag.Usage()
os.Exit(1)
}
func main() {
var (
host string
@ -57,6 +64,11 @@ func main() {
return
}
if len(flag.Args()) == 0 {
err = errors.New("no rcon commands passed")
exit(err)
}
for _, arg := range flag.Args() {
resp, err := rcon.Send(arg)
if err != nil {