Esempio n. 1
0
// Query returns a service query
func Query(ctx *cli.Context) Command {
	usage := "query [service] [method] [request]"
	desc := "Returns the response for a service query"

	return NewCommand("query", usage, desc, func(args ...string) ([]byte, error) {
		var cargs []string

		for _, arg := range args {
			if len(strings.TrimSpace(arg)) == 0 {
				continue
			}
			cargs = append(cargs, arg)
		}

		if len(cargs) < 2 {
			return []byte("query what?"), nil
		}

		rsp, err := command.QueryService(ctx, cargs[1:])
		if err != nil {
			return nil, err
		}
		return rsp, nil
	})
}
Esempio n. 2
0
func queryService(c *cli.Context) {
	rsp, err := command.QueryService(c, c.Args())
	if err != nil {
		fmt.Println(err)
		return
	}
	fmt.Println(string(rsp))
}