Skip to content

Commit 5c76979

Browse files
committed
Revert accidental removal of additional usage for repeated messages
1 parent f7ca11e commit 5c76979

File tree

1 file changed

+24
-21
lines changed

1 file changed

+24
-21
lines changed

internal/plugin/cli_flag.go

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -74,32 +74,35 @@ func flagType(field *protogen.Field) (t string, additionalUsage string, err erro
7474
return "Int64", "", nil
7575

7676
case protoreflect.MessageKind:
77-
if !field.Desc.IsList() {
78-
switch field.Desc.Message().FullName() {
79-
case "google.protobuf.Duration":
80-
additionalUsage = " (e.g. \"3.000000001s\")"
77+
switch field.Desc.Message().FullName() {
78+
case "google.protobuf.Duration":
79+
additionalUsage = " (e.g. \"3.000000001s\")"
80+
if !field.Desc.IsList() {
8181
return "Duration", additionalUsage, nil
82-
case "google.protobuf.Timestamp":
83-
additionalUsage = " (e.g. \"2017-01-15T01:30:15.01Z\")"
82+
}
83+
case "google.protobuf.Timestamp":
84+
additionalUsage = " (e.g. \"2017-01-15T01:30:15.01Z\")"
85+
if !field.Desc.IsList() {
8486
return "Timestamp", additionalUsage, nil
85-
default:
86-
var b bytes.Buffer
87-
fmt.Fprint(&b, " (json-encoded: {")
88-
var fieldDocs []string
89-
for _, f := range field.Message.Fields {
90-
kind := f.Desc.Kind().String()
91-
if f.Message != nil {
92-
kind = string(f.Message.Desc.FullName())
93-
} else if f.Enum != nil {
94-
kind = string(f.Enum.Desc.FullName())
95-
}
96-
fieldDocs = append(fieldDocs, fmt.Sprintf("%s: <%s>", f.Desc.JSONName(), kind))
87+
}
88+
default:
89+
var b bytes.Buffer
90+
fmt.Fprint(&b, " (json-encoded: {")
91+
var fieldDocs []string
92+
for _, f := range field.Message.Fields {
93+
kind := f.Desc.Kind().String()
94+
if f.Message != nil {
95+
kind = string(f.Message.Desc.FullName())
96+
} else if f.Enum != nil {
97+
kind = string(f.Enum.Desc.FullName())
9798
}
98-
fmt.Fprint(&b, strings.Join(fieldDocs, ", "))
99-
fmt.Fprint(&b, "})")
100-
additionalUsage = b.String()
99+
fieldDocs = append(fieldDocs, fmt.Sprintf("%s: <%s>", f.Desc.JSONName(), kind))
101100
}
101+
fmt.Fprint(&b, strings.Join(fieldDocs, ", "))
102+
fmt.Fprint(&b, "})")
103+
additionalUsage = b.String()
102104
}
105+
103106
fallthrough
104107

105108
case protoreflect.BytesKind, protoreflect.EnumKind, protoreflect.StringKind:

0 commit comments

Comments
 (0)