https://github.com/joshcarp/grpctl
Quickly generate a gRPC CLI or use gRPC reflection with ease
https://github.com/joshcarp/grpctl
Last synced: 3 months ago
JSON representation
Quickly generate a gRPC CLI or use gRPC reflection with ease
- Host: GitHub
- URL: https://github.com/joshcarp/grpctl
- Owner: joshcarp
- License: apache-2.0
- Created: 2021-08-29T05:32:01.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-11-16T01:34:39.000Z (over 1 year ago)
- Last Synced: 2024-08-04T08:03:38.855Z (7 months ago)
- Language: Go
- Homepage:
- Size: 23 MB
- Stars: 74
- Watchers: 2
- Forks: 1
- Open Issues: 17
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
grpctl
[]()
[](https://github.com/joshcarp/grpctl/issues)
[](https://github.com/joshcarp/grpctl/pulls)
[](/LICENSE)A golang package for easily creating custom cli tools from FileDescriptors, or through the gRPC reflection API.
# 📖 Table of contents
- [Reflection cli mode](#reflection-cli-mode)
- [File descriptor mode](#file-descriptor-mode)
- [Autocompletion](#autocompletion)
- [Flags](#flags)
- [Design](#design)
- [Contributing](#contributing)
- [License](#license)To be used like `grpcurl` against reflection APIs but with tab completion.

### 📥 Install
```bash
go get github.com/joshcarp/grpctl/cmd/grpctl
grpctl --help
```[embedmd]:# (cmd/grpctl/docs/grpctl.md bash / -a/ /WithInsecure/)
```bash
-a, --address string Address in form 'host:port'
--config string Config file (default is $HOME/.grpctl.yaml)
-H, --header stringArray Header in form 'key: value'
-h, --help help for grpctl
-p, --plaintext Dial grpc.WithInsecure
```To easily create a cli tool for your grpc APIs using the code generated `protoreflect.FileDescriptor`
To view all options that can be used, see [opts.go](opts.go).
### 📥 Install
[embedmd]:# (cmd/billingctl/main.go go /func main/ $)
```go
func main() {
cmd := &cobra.Command{
Use: "billingctl",
Short: "an example cli tool for the gcp billing api",
}
err := grpctl.BuildCommand(cmd,
grpctl.WithArgs(os.Args),
grpctl.WithFileDescriptors(
billing.File_google_cloud_billing_v1_cloud_billing_proto,
billing.File_google_cloud_billing_v1_cloud_catalog_proto,
),
)
if err != nil {
log.Print(err)
}
if err := grpctl.RunCommand(cmd, context.Background()); err != nil {
log.Print(err)
}
}
```run `grpctl completion --help` and do what it says
- `--address`
```bash
grpctl --address=
```
- it is important that the `=` is used with flags, otherwise the value will be interpreted as a command which does not exist.- `--header`
```bash
grpctl --address= -H="Foo:Bar" -H="Bar: Foo"
```
- Any white spaces at the start of the value will be stripped- `--protocol`
```bash
grpctl --address= --protocol=
```
- Specifies which rpc protocol to use, default=grpc- `--http1`
```bash
grpctl --address= --http1
```
- Use a http1.1 client instead of http2Design documents (more like a stream of consciousness) can be found in [./design](./design).
This project is still in an alpha state, any contributions are welcome see [CONTRIBUTING.md](CONTRIBUTING.md).
There is also a slack channel on gophers slack: [#grpctl](https://gophers.slack.com/archives/C02CAH9NP7H)
See [LICENSE](LICENSE) for more details.
## 🎉 Acknowledgements
- [@dancantos](https://github.com/dancantos)/[@anzboi](https://github.com/anzboi) and I were talking about [protoc-gen-cobra](https://github.com/fiorix/protoc-gen-cobra) when dan came up with the idea of using the proto descriptors to generate cobra commands on the fly.