mirror of
https://github.com/onyx-and-iris/q3rcon.git
synced 2025-01-18 10:40:47 +00:00
print usage message if not in interactive mode, and no rcon commands passed
This commit is contained in:
parent
05ee3f1912
commit
f2752f5609
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user