Skip to content

Commit

Permalink
properly respect file flag for protoc-gen-swagger (grpc-ecosystem#293)
Browse files Browse the repository at this point in the history
  • Loading branch information
tmc authored and achew22 committed Feb 16, 2018
1 parent 0a81003 commit 424b8e1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 7 additions & 3 deletions protoc-gen-swagger/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (

var (
importPrefix = flag.String("import_prefix", "", "prefix to be added to go package paths for imported proto files")
file = flag.String("file", "stdin", "where to load data from")
file = flag.String("file", "-", "where to load data from")
allowDeleteBody = flag.Bool("allow_delete_body", false, "unless set, HTTP DELETE methods may not have a body")
)

Expand Down Expand Up @@ -45,8 +45,12 @@ func main() {

glog.V(1).Info("Processing code generator request")
f := os.Stdin
if *file != "stdin" {
f, _ = os.Open("input.txt")
if *file != "-" {
var err error
f, err = os.Open(*file)
if err != nil {
glog.Fatal(err)
}
}
req, err := parseReq(f)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion protoc-gen-swagger/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func TestParseReqParam(t *testing.T) {
if !reflect.DeepEqual(pkgMap, expected) {
t.Errorf("Test 0: pkgMap parse error, expected '%v', got '%v'", expected, pkgMap)
}
checkFlags(false, "stdin", "", t, 0)
checkFlags(false, "-", "", t, 0)

clearFlags()
pkgMap = make(map[string]string)
Expand Down

0 comments on commit 424b8e1

Please sign in to comment.