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