diff --git a/changelog.md b/changelog.md index 421b9ae1f0..8d84712b3c 100644 --- a/changelog.md +++ b/changelog.md @@ -8,6 +8,7 @@ ### Changes +- [#3822](https://github.com/ignite/cli/pull/3822) Improve default scaffolded AutoCLI config - [#3838](https://github.com/ignite/cli/pull/3838) Scaffold chain with Cosmos SDK `v0.50.2`, and bump confix and x/upgrade to latest ### Fixes diff --git a/ignite/templates/typed/list/list.go b/ignite/templates/typed/list/list.go index 22f72391c1..f5fd63b9c5 100644 --- a/ignite/templates/typed/list/list.go +++ b/ignite/templates/typed/list/list.go @@ -336,27 +336,29 @@ func clientCliTxModify(replacer placeholder.Replacer, opts *typed.Options) genny return err } - var positionalArgs string + var positionalArgs, positionalArgsStr string for _, field := range opts.Fields { positionalArgs += fmt.Sprintf(`{ProtoField: "%s"}, `, field.ProtoFieldName()) + positionalArgsStr += fmt.Sprintf("[%s] ", field.ProtoFieldName()) } template := `{ RpcMethod: "Create%[2]v", - Use: "create-%[3]v", + Use: "create-%[3]v %[6]s", Short: "Create %[4]v", PositionalArgs: []*autocliv1.PositionalArgDescriptor{%[5]s}, }, { RpcMethod: "Update%[2]v", - Use: "update-%[3]v", + Use: "update-%[3]v [id] %[6]s", Short: "Update %[4]v", - PositionalArgs: []*autocliv1.PositionalArgDescriptor{%[5]s}, + PositionalArgs: []*autocliv1.PositionalArgDescriptor{{ProtoField: "id"}, %[5]s}, }, { RpcMethod: "Delete%[2]v", - Use: "delete-%[3]v", + Use: "delete-%[3]v [id]", Short: "Delete %[4]v", + PositionalArgs: []*autocliv1.PositionalArgDescriptor{{ProtoField: "id"}}, }, %[1]v` @@ -367,6 +369,7 @@ func clientCliTxModify(replacer placeholder.Replacer, opts *typed.Options) genny opts.TypeName.Kebab, opts.TypeName.Original, strings.TrimSpace(positionalArgs), + strings.TrimSpace(positionalArgsStr), ) content := replacer.Replace(f.String(), typed.PlaceholderAutoCLITx, replacement) diff --git a/ignite/templates/typed/map/map.go b/ignite/templates/typed/map/map.go index 467060ad2e..03cc93847f 100644 --- a/ignite/templates/typed/map/map.go +++ b/ignite/templates/typed/map/map.go @@ -627,30 +627,36 @@ func clientCliTxModify(replacer placeholder.Replacer, opts *typed.Options) genny return err } - var positionalArgs string + var positionalArgs, positionalArgsStr string + var indexes, indexesStr string for _, field := range opts.Fields { positionalArgs += fmt.Sprintf(`{ProtoField: "%s"}, `, field.ProtoFieldName()) + positionalArgsStr += fmt.Sprintf("[%s] ", field.ProtoFieldName()) } for _, field := range opts.Indexes { - positionalArgs += fmt.Sprintf(`{ProtoField: "%s"}, `, field.ProtoFieldName()) + indexes += fmt.Sprintf(`{ProtoField: "%s"}, `, field.ProtoFieldName()) + indexesStr += fmt.Sprintf("[%s] ", field.ProtoFieldName()) } + positionalArgs = indexes + positionalArgs + positionalArgsStr = indexesStr + positionalArgsStr template := `{ RpcMethod: "Create%[2]v", - Use: "create-%[3]v", + Use: "create-%[3]v %[6]s", Short: "Create a new %[4]v", PositionalArgs: []*autocliv1.PositionalArgDescriptor{%[5]s}, }, { RpcMethod: "Update%[2]v", - Use: "update-%[3]v", + Use: "update-%[3]v %[6]s", Short: "Update %[4]v", PositionalArgs: []*autocliv1.PositionalArgDescriptor{%[5]s}, }, { RpcMethod: "Delete%[2]v", - Use: "delete-%[3]v", + Use: "delete-%[3]v %[8]s", Short: "Delete %[4]v", + PositionalArgs: []*autocliv1.PositionalArgDescriptor{%[7]s}, }, %[1]v` @@ -661,6 +667,9 @@ func clientCliTxModify(replacer placeholder.Replacer, opts *typed.Options) genny opts.TypeName.Kebab, opts.TypeName.Original, strings.TrimSpace(positionalArgs), + strings.TrimSpace(positionalArgsStr), + strings.TrimSpace(indexes), + strings.TrimSpace(indexesStr), ) content := replacer.Replace(f.String(), typed.PlaceholderAutoCLITx, replacement) diff --git a/ignite/templates/typed/singleton/singleton.go b/ignite/templates/typed/singleton/singleton.go index d79a33f8e2..ee4526d1d4 100644 --- a/ignite/templates/typed/singleton/singleton.go +++ b/ignite/templates/typed/singleton/singleton.go @@ -460,20 +460,21 @@ func clientCliTxModify(replacer placeholder.Replacer, opts *typed.Options) genny return err } - var positionalArgs string + var positionalArgs, positionalArgsStr string for _, field := range opts.Fields { positionalArgs += fmt.Sprintf(`{ProtoField: "%s"}, `, field.ProtoFieldName()) + positionalArgsStr += fmt.Sprintf("[%s] ", field.ProtoFieldName()) } template := `{ RpcMethod: "Create%[2]v", - Use: "create-%[3]v", + Use: "create-%[3]v %[6]s", Short: "Create %[4]v", PositionalArgs: []*autocliv1.PositionalArgDescriptor{%[5]s}, }, { RpcMethod: "Update%[2]v", - Use: "update-%[3]v", + Use: "update-%[3]v %[6]s", Short: "Update %[4]v", PositionalArgs: []*autocliv1.PositionalArgDescriptor{%[5]s}, }, @@ -491,6 +492,7 @@ func clientCliTxModify(replacer placeholder.Replacer, opts *typed.Options) genny opts.TypeName.Kebab, opts.TypeName.Original, strings.TrimSpace(positionalArgs), + strings.TrimSpace(positionalArgsStr), ) content := replacer.Replace(f.String(), typed.PlaceholderAutoCLITx, replacement)