2018-01-16 20:57:04 -08:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"fmt"
|
|
|
|
"net/http"
|
|
|
|
"os"
|
|
|
|
"strings"
|
|
|
|
|
2018-01-20 08:38:58 -08:00
|
|
|
pb "mcquay.me/hwt/rpc/hwt"
|
2018-01-16 20:57:04 -08:00
|
|
|
)
|
|
|
|
|
2018-01-20 08:49:02 -08:00
|
|
|
const usage = "hwtc <server address> [subject]"
|
2018-01-16 20:57:04 -08:00
|
|
|
|
|
|
|
func main() {
|
2018-01-20 08:49:02 -08:00
|
|
|
if len(os.Args) < 3 {
|
2018-01-16 20:57:04 -08:00
|
|
|
fmt.Fprintf(os.Stderr, "%v\n", usage)
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
|
|
|
|
2018-01-20 08:49:02 -08:00
|
|
|
c := pb.NewHelloWorldProtobufClient(fmt.Sprintf("http://%s", os.Args[1]), &http.Client{})
|
2018-01-16 20:57:04 -08:00
|
|
|
|
2018-01-20 08:49:02 -08:00
|
|
|
resp, err := c.Hello(context.Background(), &pb.HelloReq{Subject: strings.Join(os.Args[2:], " ")})
|
2018-01-16 20:57:04 -08:00
|
|
|
if err != nil {
|
|
|
|
fmt.Fprintf(os.Stderr, "hello: %v\n", err)
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
|
|
|
fmt.Printf("%v\n", resp)
|
|
|
|
}
|