feat(client): add positional optional to client v2 (#16316)

Co-authored-by: Julien Robert <julien@rbrt.fr>
This commit is contained in:
Jeancarlo Barrios
2023-06-20 04:01:19 +00:00
committed by GitHub
co-authored by Julien Robert
parent 6f9152d20b
commit e078f1a49e
14 changed files with 259 additions and 30 deletions
+81 -16
View File
@@ -3779,6 +3779,7 @@ var (
md_PositionalArgDescriptor protoreflect.MessageDescriptor
fd_PositionalArgDescriptor_proto_field protoreflect.FieldDescriptor
fd_PositionalArgDescriptor_varargs protoreflect.FieldDescriptor
fd_PositionalArgDescriptor_optional protoreflect.FieldDescriptor
)
func init() {
@@ -3786,6 +3787,7 @@ func init() {
md_PositionalArgDescriptor = File_cosmos_autocli_v1_options_proto.Messages().ByName("PositionalArgDescriptor")
fd_PositionalArgDescriptor_proto_field = md_PositionalArgDescriptor.Fields().ByName("proto_field")
fd_PositionalArgDescriptor_varargs = md_PositionalArgDescriptor.Fields().ByName("varargs")
fd_PositionalArgDescriptor_optional = md_PositionalArgDescriptor.Fields().ByName("optional")
}
var _ protoreflect.Message = (*fastReflection_PositionalArgDescriptor)(nil)
@@ -3865,6 +3867,12 @@ func (x *fastReflection_PositionalArgDescriptor) Range(f func(protoreflect.Field
return
}
}
if x.Optional != false {
value := protoreflect.ValueOfBool(x.Optional)
if !f(fd_PositionalArgDescriptor_optional, value) {
return
}
}
}
// Has reports whether a field is populated.
@@ -3884,6 +3892,8 @@ func (x *fastReflection_PositionalArgDescriptor) Has(fd protoreflect.FieldDescri
return x.ProtoField != ""
case "cosmos.autocli.v1.PositionalArgDescriptor.varargs":
return x.Varargs != false
case "cosmos.autocli.v1.PositionalArgDescriptor.optional":
return x.Optional != false
default:
if fd.IsExtension() {
panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.autocli.v1.PositionalArgDescriptor"))
@@ -3904,6 +3914,8 @@ func (x *fastReflection_PositionalArgDescriptor) Clear(fd protoreflect.FieldDesc
x.ProtoField = ""
case "cosmos.autocli.v1.PositionalArgDescriptor.varargs":
x.Varargs = false
case "cosmos.autocli.v1.PositionalArgDescriptor.optional":
x.Optional = false
default:
if fd.IsExtension() {
panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.autocli.v1.PositionalArgDescriptor"))
@@ -3926,6 +3938,9 @@ func (x *fastReflection_PositionalArgDescriptor) Get(descriptor protoreflect.Fie
case "cosmos.autocli.v1.PositionalArgDescriptor.varargs":
value := x.Varargs
return protoreflect.ValueOfBool(value)
case "cosmos.autocli.v1.PositionalArgDescriptor.optional":
value := x.Optional
return protoreflect.ValueOfBool(value)
default:
if descriptor.IsExtension() {
panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.autocli.v1.PositionalArgDescriptor"))
@@ -3950,6 +3965,8 @@ func (x *fastReflection_PositionalArgDescriptor) Set(fd protoreflect.FieldDescri
x.ProtoField = value.Interface().(string)
case "cosmos.autocli.v1.PositionalArgDescriptor.varargs":
x.Varargs = value.Bool()
case "cosmos.autocli.v1.PositionalArgDescriptor.optional":
x.Optional = value.Bool()
default:
if fd.IsExtension() {
panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.autocli.v1.PositionalArgDescriptor"))
@@ -3974,6 +3991,8 @@ func (x *fastReflection_PositionalArgDescriptor) Mutable(fd protoreflect.FieldDe
panic(fmt.Errorf("field proto_field of message cosmos.autocli.v1.PositionalArgDescriptor is not mutable"))
case "cosmos.autocli.v1.PositionalArgDescriptor.varargs":
panic(fmt.Errorf("field varargs of message cosmos.autocli.v1.PositionalArgDescriptor is not mutable"))
case "cosmos.autocli.v1.PositionalArgDescriptor.optional":
panic(fmt.Errorf("field optional of message cosmos.autocli.v1.PositionalArgDescriptor is not mutable"))
default:
if fd.IsExtension() {
panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.autocli.v1.PositionalArgDescriptor"))
@@ -3991,6 +4010,8 @@ func (x *fastReflection_PositionalArgDescriptor) NewField(fd protoreflect.FieldD
return protoreflect.ValueOfString("")
case "cosmos.autocli.v1.PositionalArgDescriptor.varargs":
return protoreflect.ValueOfBool(false)
case "cosmos.autocli.v1.PositionalArgDescriptor.optional":
return protoreflect.ValueOfBool(false)
default:
if fd.IsExtension() {
panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.autocli.v1.PositionalArgDescriptor"))
@@ -4067,6 +4088,9 @@ func (x *fastReflection_PositionalArgDescriptor) ProtoMethods() *protoiface.Meth
if x.Varargs {
n += 2
}
if x.Optional {
n += 2
}
if x.unknownFields != nil {
n += len(x.unknownFields)
}
@@ -4096,6 +4120,16 @@ func (x *fastReflection_PositionalArgDescriptor) ProtoMethods() *protoiface.Meth
i -= len(x.unknownFields)
copy(dAtA[i:], x.unknownFields)
}
if x.Optional {
i--
if x.Optional {
dAtA[i] = 1
} else {
dAtA[i] = 0
}
i--
dAtA[i] = 0x18
}
if x.Varargs {
i--
if x.Varargs {
@@ -4214,6 +4248,26 @@ func (x *fastReflection_PositionalArgDescriptor) ProtoMethods() *protoiface.Meth
}
}
x.Varargs = bool(v != 0)
case 3:
if wireType != 0 {
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Optional", wireType)
}
var v int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow
}
if iNdEx >= l {
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
v |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
x.Optional = bool(v != 0)
default:
iNdEx = preIndex
skippy, err := runtime.Skip(dAtA[iNdEx:])
@@ -4622,8 +4676,11 @@ type PositionalArgDescriptor struct {
ProtoField string `protobuf:"bytes,1,opt,name=proto_field,json=protoField,proto3" json:"proto_field,omitempty"`
// varargs makes a positional parameter a varargs parameter. This can only be
// applied to last positional parameter and the proto_field must a repeated
// field.
// field. Note: It is mutually exclusive with optional.
Varargs bool `protobuf:"varint,2,opt,name=varargs,proto3" json:"varargs,omitempty"`
// optional makes a positional parameter optional. This can only be applied
// to the last positional parameter. Note: It is mutually exclusive with varargs.
Optional bool `protobuf:"varint,3,opt,name=optional,proto3" json:"optional,omitempty"`
}
func (x *PositionalArgDescriptor) Reset() {
@@ -4660,6 +4717,13 @@ func (x *PositionalArgDescriptor) GetVarargs() bool {
return false
}
func (x *PositionalArgDescriptor) GetOptional() bool {
if x != nil {
return x.Optional
}
return false
}
var File_cosmos_autocli_v1_options_proto protoreflect.FileDescriptor
var file_cosmos_autocli_v1_options_proto_rawDesc = []byte{
@@ -4745,25 +4809,26 @@ var file_cosmos_autocli_v1_options_proto_rawDesc = []byte{
0x63, 0x61, 0x74, 0x65, 0x64, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x13, 0x73, 0x68, 0x6f,
0x72, 0x74, 0x68, 0x61, 0x6e, 0x64, 0x44, 0x65, 0x70, 0x72, 0x65, 0x63, 0x61, 0x74, 0x65, 0x64,
0x12, 0x16, 0x0a, 0x06, 0x68, 0x69, 0x64, 0x64, 0x65, 0x6e, 0x18, 0x08, 0x20, 0x01, 0x28, 0x08,
0x52, 0x06, 0x68, 0x69, 0x64, 0x64, 0x65, 0x6e, 0x22, 0x54, 0x0a, 0x17, 0x50, 0x6f, 0x73, 0x69,
0x52, 0x06, 0x68, 0x69, 0x64, 0x64, 0x65, 0x6e, 0x22, 0x70, 0x0a, 0x17, 0x50, 0x6f, 0x73, 0x69,
0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x41, 0x72, 0x67, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70,
0x74, 0x6f, 0x72, 0x12, 0x1f, 0x0a, 0x0b, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x5f, 0x66, 0x69, 0x65,
0x6c, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x46,
0x69, 0x65, 0x6c, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x61, 0x72, 0x61, 0x72, 0x67, 0x73, 0x18,
0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x76, 0x61, 0x72, 0x61, 0x72, 0x67, 0x73, 0x42, 0xb9,
0x01, 0x0a, 0x15, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x75,
0x74, 0x6f, 0x63, 0x6c, 0x69, 0x2e, 0x76, 0x31, 0x42, 0x0c, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e,
0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x2c, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73,
0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f,
0x73, 0x2f, 0x61, 0x75, 0x74, 0x6f, 0x63, 0x6c, 0x69, 0x2f, 0x76, 0x31, 0x3b, 0x61, 0x75, 0x74,
0x6f, 0x63, 0x6c, 0x69, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x41, 0x58, 0xaa, 0x02, 0x11, 0x43,
0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x75, 0x74, 0x6f, 0x63, 0x6c, 0x69, 0x2e, 0x56, 0x31,
0xca, 0x02, 0x11, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x41, 0x75, 0x74, 0x6f, 0x63, 0x6c,
0x69, 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x1d, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x41, 0x75,
0x74, 0x6f, 0x63, 0x6c, 0x69, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61,
0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x13, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x3a, 0x3a, 0x41,
0x75, 0x74, 0x6f, 0x63, 0x6c, 0x69, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x33,
0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x76, 0x61, 0x72, 0x61, 0x72, 0x67, 0x73, 0x12, 0x1a,
0x0a, 0x08, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08,
0x52, 0x08, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x42, 0xb9, 0x01, 0x0a, 0x15, 0x63,
0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x75, 0x74, 0x6f, 0x63, 0x6c,
0x69, 0x2e, 0x76, 0x31, 0x42, 0x0c, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x50, 0x72, 0x6f,
0x74, 0x6f, 0x50, 0x01, 0x5a, 0x2c, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e,
0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x61, 0x75,
0x74, 0x6f, 0x63, 0x6c, 0x69, 0x2f, 0x76, 0x31, 0x3b, 0x61, 0x75, 0x74, 0x6f, 0x63, 0x6c, 0x69,
0x76, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x41, 0x58, 0xaa, 0x02, 0x11, 0x43, 0x6f, 0x73, 0x6d, 0x6f,
0x73, 0x2e, 0x41, 0x75, 0x74, 0x6f, 0x63, 0x6c, 0x69, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x11, 0x43,
0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x41, 0x75, 0x74, 0x6f, 0x63, 0x6c, 0x69, 0x5c, 0x56, 0x31,
0xe2, 0x02, 0x1d, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x41, 0x75, 0x74, 0x6f, 0x63, 0x6c,
0x69, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61,
0xea, 0x02, 0x13, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x3a, 0x3a, 0x41, 0x75, 0x74, 0x6f, 0x63,
0x6c, 0x69, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (