Skip to content

Commit 3dd1900

Browse files
committed
fix(client/v2): fix short and long command description if not set
1 parent 79246d2 commit 3dd1900

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

client/v2/autocli/common.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ func (b *Builder) buildMethodCommandCommon(descriptor protoreflect.MethodDescrip
2727
options = &autocliv1.RpcCommandOptions{}
2828
}
2929

30+
short := options.Short
31+
if short == "" {
32+
short = fmt.Sprintf("Execute the %s RPC method", descriptor.Name())
33+
}
34+
3035
long := options.Long
3136
if long == "" {
3237
long = util.DescriptorDocs(descriptor)
@@ -44,7 +49,7 @@ func (b *Builder) buildMethodCommandCommon(descriptor protoreflect.MethodDescrip
4449
SilenceUsage: false,
4550
Use: use,
4651
Long: long,
47-
Short: options.Short,
52+
Short: short,
4853
Example: options.Example,
4954
Aliases: options.Alias,
5055
SuggestFor: options.SuggestFor,

client/v2/internal/util/util.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,13 @@ import (
88
"cosmossdk.io/client/v2/internal/strcase"
99
)
1010

11+
// DescriptorName returns the name of the descriptor in kebab case.
1112
func DescriptorKebabName(descriptor protoreflect.Descriptor) string {
1213
return strcase.ToKebab(string(descriptor.Name()))
1314
}
1415

16+
// DescriptorDocs returns the leading comments of the descriptor.
17+
// TODO this does not work, to fix.
1518
func DescriptorDocs(descriptor protoreflect.Descriptor) string {
1619
return descriptor.ParentFile().SourceLocations().ByDescriptor(descriptor).LeadingComments
1720
}

0 commit comments

Comments
 (0)