An open API service indexing awesome lists of open source software.

https://github.com/einride/aip-cli-go

Generate command line interfaces to your gRPC services.
https://github.com/einride/aip-cli-go

aip api-management cli command-line go golang grpc protobuf protocol-buffers

Last synced: 11 months ago
JSON representation

Generate command line interfaces to your gRPC services.

Awesome Lists containing this project

README

          

# AIP CLI Go

Generate command line interfaces to your [AIP](https://aip.dev) gRPC services.

## How to

### Step 1: Install the plugin

```bash
$ GOBIN=$PWD/build go install go.einride.tech/aip-cli/cmd/protoc-gen-go-aip-cli
```

### Step 2: Configure the code generator

The following example uses a
[buf generate](https://docs.buf.build/generate/usage) template to configure the
CLI generator.

[buf.gen.example.yaml](./proto/buf.gen.example.yaml):

```yaml
version: v1

managed:
enabled: true
go_package_prefix:
default: go.einride.tech/aip-cli/cmd/examplectl
except:
- buf.build/googleapis/googleapis

plugins:
# The CLI generator requires the stubs generated by protoc-gen-go.
- name: go
out: cmd/examplectl
opt: module=go.einride.tech/aip-cli/cmd/examplectl

# The CLI generator optionally generates a root command and a main file
# to the root of the output module.
- name: go-aip-cli
out: cmd/examplectl
strategy: all
opt:
- module=go.einride.tech/aip-cli/cmd/examplectl
- root=examplectl
- gcloud_identity_tokens=true
```

### Step 3: Generate the code

```bash
$ buf generate \
--template buf.gen.example.yaml \
--path einride/example/freight
```

### Step 4: Install the CLI

```bash
$ go install ./cmd/examplectl
```

### Step 5: Use the CLI

```bash
$ examplectl help freight

this api represents a simple freight service

Usage:
examplectl freight [command]

Available Commands:
batch-get-sites batch get sites
create-shipment create a shipment
create-shipper create a shipper
create-site create a site
delete-shipment delete a shipment
delete-shipper delete a shipper
delete-site delete a site
get-shipment get a shipment
get-shipper get a shipper
get-site get a site
list-shipments list shipments for a shipper
list-shippers list shippers
list-sites list sites for a shipper
update-shipment update a shipment
update-shipper update a shipper
update-site update a site

Flags:
-h, --help help for freight

Global Flags:
--address string address to connect to
--insecure make insecure client connection (only on localhost)
--token string bearer token used by client
-v, --verbose print verbose output

Use "examplectl freight [command] --help" for more information about a command.
```