-
Notifications
You must be signed in to change notification settings - Fork 5
/
protoxy.go
35 lines (29 loc) · 931 Bytes
/
protoxy.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Package cmd handles the command-line interface for protoxy.
package cmd
import (
"fmt"
"os"
"github.com/spf13/cobra"
)
func init() {
rootCmd.PersistentFlags().StringSliceVarP(&importPaths, "import-paths", "I", nil, "paths to search for imports declared in your proto files. Defaults to current directory.")
rootCmd.MarkPersistentFlagRequired("proto")
rootCmd.PersistentFlags().Uint16Var(&port, "port", 7777, "the port to start the server on")
}
// Flags
var importPaths []string
var port uint16
var rootCmd = cobra.Command{
Use: "protoxy PROTO_FILES",
Short: "Start the proxy server",
Long: "Start a proxy server that converts JSON request bodies to Protocol Buffers. See github.com/camgraff/protoxy for documentation",
Args: cobra.MinimumNArgs(1),
RunE: startCmdFunc,
}
// Execute executes the root command.
func Execute() {
if err := rootCmd.Execute(); err != nil {
fmt.Println(err)
os.Exit(1)
}
}