Skip to content

Commit

Permalink
add --proto flag (#216)
Browse files Browse the repository at this point in the history
  • Loading branch information
ktr0731 authored Jan 5, 2020
1 parent 3c0a83d commit 75a8e8d
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 1 deletion.
7 changes: 7 additions & 0 deletions app/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ import (
"context"
"fmt"
"io"
"os"
"text/tabwriter"

"github.com/ktr0731/evans/cache"
"github.com/ktr0731/evans/config"
"github.com/ktr0731/evans/cui"
"github.com/ktr0731/evans/logger"
"github.com/ktr0731/evans/meta"
"github.com/ktr0731/evans/mode"
"github.com/ktr0731/evans/prompt"
Expand Down Expand Up @@ -44,6 +46,10 @@ func runFunc(
return errors.Wrap(err, "invalid flag condition")
}

if flags.meta.verbose {
logger.SetOutput(os.Stderr)
}

switch {
case flags.meta.edit:
if err := config.Edit(); err != nil {
Expand Down Expand Up @@ -171,6 +177,7 @@ func bindFlags(f *pflag.FlagSet, flags *flags, w io.Writer) {
f.StringVar(&flags.common.pkg, "package", "", "default package")
f.StringVar(&flags.common.service, "service", "", "default service")
f.StringSliceVar(&flags.common.path, "path", nil, "proto file paths")
f.StringSliceVar(&flags.common.proto, "proto", nil, "proto file names")
f.StringVar(&flags.common.host, "host", "", "gRPC server host")
f.StringVarP(&flags.common.port, "port", "p", "50051", "gRPC server port")
f.Var(
Expand Down
1 change: 1 addition & 0 deletions app/flag.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ type flags struct {
pkg string
service string
path []string
proto []string
host string
port string
header map[string][]string
Expand Down
1 change: 1 addition & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ func bindFlags(vp *viper.Viper, fs *pflag.FlagSet) {
// kv defines the mapping from a viper config name to a flag name.
kv := map[string]string{
"default.protoPath": "path",
"default.protoFile": "proto",
"default.package": "package",
"default.service": "service",
"server.host": "host",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

[default]
package = ""
protofile = []
protofile = ["hoge","fuga"]
protopath = ["foo","bar"]
service = ""

Expand Down
1 change: 1 addition & 0 deletions e2e/old_cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,7 @@ Options:
--package string default package
--service string default service
--path strings proto file paths (default "[]")
--proto strings proto file names (default "[]")
--host string gRPC server host
--port, -p string gRPC server port (default "50051")
--header slice of strings default headers that set to each requests (example: foo=bar) (default "[]")
Expand Down

0 comments on commit 75a8e8d

Please sign in to comment.