style: bank & autocli (#15659)
Co-authored-by: Sam Ricotta <samanthalricotta@gmail.com> Co-authored-by: samricotta <37125168+samricotta@users.noreply.github.com>
This commit is contained in:
co-authored by
Sam Ricotta
samricotta
parent
6aaa3cf2ed
commit
0c905e8707
@@ -121,5 +121,5 @@ func (b *Builder) outOrStdoutFormat(cmd *cobra.Command, out []byte) error {
|
||||
}
|
||||
_, err = fmt.Fprintln(cmd.OutOrStdout(), string(out))
|
||||
|
||||
return nil
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -10,11 +10,11 @@ import (
|
||||
|
||||
type durationType struct{}
|
||||
|
||||
func (t durationType) NewValue(context.Context, *Builder) Value {
|
||||
func (d durationType) NewValue(context.Context, *Builder) Value {
|
||||
return &durationValue{}
|
||||
}
|
||||
|
||||
func (t durationType) DefaultValue() string {
|
||||
func (d durationType) DefaultValue() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
@@ -22,30 +22,30 @@ type durationValue struct {
|
||||
value *durationpb.Duration
|
||||
}
|
||||
|
||||
func (a durationValue) Get(protoreflect.Value) (protoreflect.Value, error) {
|
||||
if a.value == nil {
|
||||
func (d durationValue) Get(protoreflect.Value) (protoreflect.Value, error) {
|
||||
if d.value == nil {
|
||||
return protoreflect.Value{}, nil
|
||||
}
|
||||
return protoreflect.ValueOfMessage(a.value.ProtoReflect()), nil
|
||||
return protoreflect.ValueOfMessage(d.value.ProtoReflect()), nil
|
||||
}
|
||||
|
||||
func (v durationValue) String() string {
|
||||
if v.value == nil {
|
||||
func (d durationValue) String() string {
|
||||
if d.value == nil {
|
||||
return ""
|
||||
}
|
||||
return v.value.AsDuration().String()
|
||||
return d.value.AsDuration().String()
|
||||
}
|
||||
|
||||
func (v *durationValue) Set(s string) error {
|
||||
func (d *durationValue) Set(s string) error {
|
||||
dur, err := time.ParseDuration(s)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
v.value = durationpb.New(dur)
|
||||
d.value = durationpb.New(dur)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (v durationValue) Type() string {
|
||||
func (d durationValue) Type() string {
|
||||
return "duration"
|
||||
}
|
||||
|
||||
@@ -29,22 +29,22 @@ func (t timestampValue) Get(protoreflect.Value) (protoreflect.Value, error) {
|
||||
return protoreflect.ValueOfMessage(t.value.ProtoReflect()), nil
|
||||
}
|
||||
|
||||
func (v timestampValue) String() string {
|
||||
if v.value == nil {
|
||||
func (t timestampValue) String() string {
|
||||
if t.value == nil {
|
||||
return ""
|
||||
}
|
||||
return v.value.AsTime().Format(time.RFC3339)
|
||||
return t.value.AsTime().Format(time.RFC3339)
|
||||
}
|
||||
|
||||
func (v *timestampValue) Set(s string) error {
|
||||
t, err := time.Parse(time.RFC3339, s)
|
||||
func (t *timestampValue) Set(s string) error {
|
||||
time, err := time.Parse(time.RFC3339, s)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
v.value = timestamppb.New(t)
|
||||
t.value = timestamppb.New(time)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (v timestampValue) Type() string {
|
||||
func (t timestampValue) Type() string {
|
||||
return "timestamp (RFC 3339)"
|
||||
}
|
||||
|
||||
@@ -367,7 +367,3 @@ func TestEnhanceMessageCommand(t *testing.T) {
|
||||
err = b.enhanceCommandCommon(cmd, options, customCommands, enhanceMsg)
|
||||
assert.NilError(t, err)
|
||||
}
|
||||
|
||||
type testMessageServer struct {
|
||||
testpb.UnimplementedMsgServer
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user