Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/joshcarp/grpctl
Quickly generate a gRPC CLI or use gRPC reflection with ease
https://github.com/joshcarp/grpctl
Last synced: 26 days 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 (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-11-16T01:34:39.000Z (7 months ago)
- Last Synced: 2024-02-16T08:38:54.270Z (4 months ago)
- Language: Go
- Homepage:
- Size: 23 MB
- Stars: 73
- Watchers: 2
- Forks: 1
- Open Issues: 17
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Lists
- awesome-stars - joshcarp/grpctl - Quickly generate a gRPC CLI or use gRPC reflection with ease (Go)
README
grpctl
[![Status](https://img.shields.io/badge/status-active-success.svg)]()
[![GitHub Issues](https://img.shields.io/github/issues/joshcarp/grpctl)](https://github.com/joshcarp/grpctl/issues)
[![GitHub Pull Requests](https://img.shields.io/github/issues-pr/joshcarp/grpctl)](https://github.com/joshcarp/grpctl/pulls)
[![License](https://img.shields.io/badge/license-apache2-blue.svg)](/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.
![grpctl](./grpctl.svg)
### 📥 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).![examplectl](./examplectl.gif)
### 📥 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.