Skip to content

Commit

Permalink
feat(client/v2): override short description in generated command (#20266
Browse files Browse the repository at this point in the history
)

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
(cherry picked from commit 7a505ad)

# Conflicts:
#	api/cosmos/autocli/v1/options.pulsar.go
#	client/v2/CHANGELOG.md
#	proto/cosmos/autocli/v1/options.proto
  • Loading branch information
johnletey authored and mergify[bot] committed May 3, 2024
1 parent bd886bb commit 484b6a7
Show file tree
Hide file tree
Showing 6 changed files with 339 additions and 4 deletions.
297 changes: 297 additions & 0 deletions api/cosmos/autocli/v1/options.pulsar.go

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions client/v2/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,18 @@ Ref: https://keepachangelog.com/en/1.0.0/

## [Unreleased]

<<<<<<< HEAD
## [v2.0.0-beta.2] - 2024-XX-XX
=======
<!-- ## [v2.1.0-beta.1] to be tagged after v0.51 final or in SDK agnostic version -->

### Features

* [#18626](https://github.com/cosmos/cosmos-sdk/pull/18626) Support for off-chain signing and verification of a file.
* [#18461](https://github.com/cosmos/cosmos-sdk/pull/18461) Support governance proposals.
* [#19039](https://github.com/cosmos/cosmos-sdk/pull/19039) Add support for pubkey in autocli.
* [#20266](https://github.com/cosmos/cosmos-sdk/pull/20266) Ability to override the short description in AutoCLI-generated top-level commands.
>>>>>>> 7a505ade6 (feat(client/v2): override short description in generated command (#20266))
### Improvements

Expand Down
12 changes: 10 additions & 2 deletions client/v2/autocli/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,11 @@ func (b *Builder) enhanceCommandCommon(
// enhanceQuery enhances the provided query command with the autocli commands for a module.
func enhanceQuery(builder *Builder, moduleName string, cmd *cobra.Command, modOpts *autocliv1.ModuleOptions) error {
if queryCmdDesc := modOpts.Query; queryCmdDesc != nil {
subCmd := topLevelCmd(cmd.Context(), moduleName, fmt.Sprintf("Querying commands for the %s module", moduleName))
short := queryCmdDesc.Short
if short == "" {
short = fmt.Sprintf("Querying commands for the %s module", moduleName)
}
subCmd := topLevelCmd(cmd.Context(), moduleName, short)
if err := builder.AddQueryServiceCommands(subCmd, queryCmdDesc); err != nil {
return err
}
Expand All @@ -189,7 +193,11 @@ func enhanceQuery(builder *Builder, moduleName string, cmd *cobra.Command, modOp
// enhanceMsg enhances the provided msg command with the autocli commands for a module.
func enhanceMsg(builder *Builder, moduleName string, cmd *cobra.Command, modOpts *autocliv1.ModuleOptions) error {
if txCmdDesc := modOpts.Tx; txCmdDesc != nil {
subCmd := topLevelCmd(cmd.Context(), moduleName, fmt.Sprintf("Transactions commands for the %s module", moduleName))
short := txCmdDesc.Short
if short == "" {
short = fmt.Sprintf("Transactions commands for the %s module", moduleName)
}
subCmd := topLevelCmd(cmd.Context(), moduleName, short)
if err := builder.AddMsgServiceCommands(subCmd, txCmdDesc); err != nil {
return err
}
Expand Down
6 changes: 5 additions & 1 deletion client/v2/autocli/msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ func (b *Builder) AddMsgServiceCommands(cmd *cobra.Command, cmdDescriptor *autoc
for cmdName, subCmdDescriptor := range cmdDescriptor.SubCommands {
subCmd := findSubCommand(cmd, cmdName)
if subCmd == nil {
subCmd = topLevelCmd(cmd.Context(), cmdName, fmt.Sprintf("Tx commands for the %s service", subCmdDescriptor.Service))
short := cmdDescriptor.Short
if cmdDescriptor.Short == "" {
short = fmt.Sprintf("Tx commands for the %s service", subCmdDescriptor.Service)
}
subCmd = topLevelCmd(cmd.Context(), cmdName, short)
}

// Add recursive sub-commands if there are any. This is used for nested services.
Expand Down
6 changes: 5 additions & 1 deletion client/v2/autocli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@ func (b *Builder) AddQueryServiceCommands(cmd *cobra.Command, cmdDescriptor *aut
for cmdName, subCmdDesc := range cmdDescriptor.SubCommands {
subCmd := findSubCommand(cmd, cmdName)
if subCmd == nil {
subCmd = topLevelCmd(cmd.Context(), cmdName, fmt.Sprintf("Querying commands for the %s service", subCmdDesc.Service))
short := cmdDescriptor.Short
if short == "" {
short = fmt.Sprintf("Querying commands for the %s service", subCmdDesc.Service)
}
subCmd = topLevelCmd(cmd.Context(), cmdName, short)
}

if err := b.AddQueryServiceCommands(subCmd, subCmdDesc); err != nil {
Expand Down
11 changes: 11 additions & 0 deletions proto/cosmos/autocli/v1/options.proto
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,17 @@ message ServiceCommandDescriptor {
// different protobuf services. The map key is used as the name of the
// sub-command.
map<string, ServiceCommandDescriptor> sub_commands = 3;
<<<<<<< HEAD

Check failure on line 33 in proto/cosmos/autocli/v1/options.proto

View workflow job for this annotation

GitHub Actions / lint

syntax error: unexpected '<'
=======

// enhance_custom_commands specifies whether to skip the service when generating commands, if a custom command already
// exists, or enhance the existing command. If set to true, the custom command will be enhanced with the services from
// gRPC. otherwise when a custom command exists, no commands will be generated for the service.
bool enhance_custom_command = 4;

// short is an optional parameter used to override the short description of the auto generated command.
string short = 5;
>>>>>>> 7a505ade6 (feat(client/v2): override short description in generated command (#20266))

Check failure on line 43 in proto/cosmos/autocli/v1/options.proto

View workflow job for this annotation

GitHub Actions / lint

syntax error: unexpected '>'

Check failure on line 43 in proto/cosmos/autocli/v1/options.proto

View workflow job for this annotation

GitHub Actions / lint

invalid syntax in float value: 7a505ade6

Check failure on line 43 in proto/cosmos/autocli/v1/options.proto

View workflow job for this annotation

GitHub Actions / lint

invalid character
}

// RpcCommandOptions specifies options for commands generated from protobuf
Expand Down

0 comments on commit 484b6a7

Please sign in to comment.