项目作者: bobheadxi

项目描述 :
🐒 Package ctl enables drop-in gRPC client integration for your service into command-line applications
高级语言: Go
项目地址: git://github.com/bobheadxi/ctl.git
创建时间: 2018-11-05T08:19:52Z
项目社区:https://github.com/bobheadxi/ctl

开源协议:

下载


ctl

Package ctl provides a library that makes it easy to embed a simple, minimal
client into your Go program to interact with your gRPC server.

Usage

API is still WIP and subject to change, but here’s the general gist:

  1. import "github.com/bobheadxi/ctl"
  2. func main() {
  3. // instantiate your gRPC client
  4. c, _ := client.New( /* ... */ )
  5. // create a controller
  6. controller, _ := ctl.New(c)
  7. // show help if you want
  8. if os.Args != nil && len(os.Args) == 1 && os.Args[0] == "help" {
  9. controller.Help(os.Stdout)
  10. return
  11. }
  12. // execute command
  13. out, _ := controller.Exec(os.Args[0:], os.Stdout)
  14. // print the output
  15. fmt.Printf("%v\n", out)
  16. }

In a command line application, you can then run:

  1. $> my-command SomeRPCCall RequestParam=blah AnotherRequestParam=wow