grpccmd

package
v0.2.134 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 25, 2019 License: BSD-2-Clause Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var API_URL_FLAG = cli.StringFlag{
	Name:   "api-url",
	Value:  "grpc://localhost:20180",
	EnvVar: "N0CLI_API_URL",
}
View Source
var OUTPUT_TYPE_FLAG = cli.StringFlag{
	Name:  "output, o",
	Value: "table",
	Usage: "Select a output method from `table,json`",
}

Functions

func Connect2gRPC

func Connect2gRPC(c *cli.Context) (*grpc.ClientConn, error)

func GenerateAction

func GenerateAction(ctx context.Context, output OutputMessage, newGrpcClient interface{}, targetGRPC interface{}, argsKeys []string) func(*cli.Context) error

func GenerateFlags

func GenerateFlags(targetGRPC interface{}, argsKeys []string) []cli.Flag

"name" is standard field, so get by args

func GenerateGRPCGetter

func GenerateGRPCGetter(f interface{}, argsKeys []string, newGrpcClient interface{}) func(c *cli.Context, ctx context.Context, conn *grpc.ClientConn) (proto.Message, error)

this function panic when set an argument that is not gRPC method.

func ParseJsonTag

func ParseJsonTag(tag string) string

func PrintGrpcError

func PrintGrpcError(err error)

Types

type OutputMessage

type OutputMessage func(*cli.Context, proto.Message) error

type Outputter

type Outputter struct {
	Out io.Writer
	Err io.Writer
}

func DefaultOutputer

func DefaultOutputer() *Outputter

func (Outputter) GenerateOutputMethod

func (o Outputter) GenerateOutputMethod(tableKeys []string) OutputMessage

func (Outputter) OutputJson

func (o Outputter) OutputJson(m proto.Message) error

func (Outputter) OutputJsonAsOutputMessage

func (o Outputter) OutputJsonAsOutputMessage(c *cli.Context, m proto.Message) error

func (Outputter) OutputNone

func (o Outputter) OutputNone(c *cli.Context, m proto.Message) error

func (Outputter) OutputTable

func (o Outputter) OutputTable(m proto.Message, keys []string) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL