https://github.com/bobheadxi/ctl
🐒 Package ctl enables drop-in gRPC client integration for your service into command-line applications
https://github.com/bobheadxi/ctl
cli client golang grpc grpc-client reflection
Last synced: 8 months ago
JSON representation
🐒 Package ctl enables drop-in gRPC client integration for your service into command-line applications
- Host: GitHub
- URL: https://github.com/bobheadxi/ctl
- Owner: bobheadxi
- Created: 2018-11-05T08:19:52.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-11-05T19:34:37.000Z (over 7 years ago)
- Last Synced: 2025-04-10T12:50:12.954Z (12 months ago)
- Topics: cli, client, golang, grpc, grpc-client, reflection
- Language: Go
- Homepage:
- Size: 3.91 KB
- Stars: 4
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 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:
```go
import "github.com/bobheadxi/ctl"
func main() {
// instantiate your gRPC client
c, _ := client.New( /* ... */ )
// create a controller
controller, _ := ctl.New(c)
// show help if you want
if os.Args != nil && len(os.Args) == 1 && os.Args[0] == "help" {
controller.Help(os.Stdout)
return
}
// execute command
out, _ := controller.Exec(os.Args[0:], os.Stdout)
// print the output
fmt.Printf("%v\n", out)
}
```
In a command line application, you can then run:
```sh
$> my-command SomeRPCCall RequestParam=blah AnotherRequestParam=wow
```