diff --git a/changelog.md b/changelog.md index 148c76d30f..a6093b4f98 100644 --- a/changelog.md +++ b/changelog.md @@ -16,6 +16,7 @@ - [#3559](https://github.com/ignite/cli/pull/3559) Bump network plugin version to `v0.1.1` - [#3581](https://github.com/ignite/cli/pull/3581) Bump cometbft and cometbft-db in the template - [#3522](https://github.com/ignite/cli/pull/3522) Remove indentation from `chain serve` output +- [#3346](https://github.com/ignite/cli/issues/3346) Improve scaffold query --help - [#3601](https://github.com/ignite/cli/pull/3601) Update ts-relayer version to `0.10.0` - [#3658](https://github.com/ignite/cli/pull/3658) Rename Marshaler to Codec in EncodingConfig - [#3653](https://github.com/ignite/cli/pull/3653) Add "app" extension to plugin binaries diff --git a/ignite/cmd/scaffold.go b/ignite/cmd/scaffold.go index a7ad440366..c182f72a79 100644 --- a/ignite/cmd/scaffold.go +++ b/ignite/cmd/scaffold.go @@ -29,6 +29,28 @@ const ( msgCommitPrompt = "Do you want to proceed without committing your saved changes" statusScaffolding = "Scaffolding..." + + supportFieldTypes = ` +Currently supports: + +| Type | Alias | Index | Code Type | Description | +|--------------|---------|-------|-----------|---------------------------------| +| string | - | yes | string | Text type | +| array.string | strings | no | []string | List of text type | +| bool | - | yes | bool | Boolean type | +| int | - | yes | int32 | Integer type | +| array.int | ints | no | []int32 | List of integers types | +| uint | - | yes | uint64 | Unsigned integer type | +| array.uint | uints | no | []uint64 | List of unsigned integers types | +| coin | - | no | sdk.Coin | Cosmos SDK coin type | +| array.coin | coins | no | sdk.Coins | List of Cosmos SDK coin types | + +Field Usage: + - fieldName + - fieldName:fieldType + +If no :fieldType, default (string) is used +` ) // NewScaffold returns a command that groups scaffolding related sub commands. diff --git a/ignite/cmd/scaffold_list.go b/ignite/cmd/scaffold_list.go index e9478b84b5..ac835e2421 100644 --- a/ignite/cmd/scaffold_list.go +++ b/ignite/cmd/scaffold_list.go @@ -55,19 +55,7 @@ array.coin. An example of using field types: ignite scaffold list pool amount:coin tags:array.string height:int -Supported types: - -| Type | Alias | Index | Code Type | Description | -|--------------|---------|-------|-----------|---------------------------------| -| string | - | yes | string | Text type | -| array.string | strings | no | []string | List of text type | -| bool | - | yes | bool | Boolean type | -| int | - | yes | int32 | Integer type | -| array.int | ints | no | []int32 | List of integers types | -| uint | - | yes | uint64 | Unsigned integer type | -| array.uint | uints | no | []uint64 | List of unsigned integers types | -| coin | - | no | sdk.Coin | Cosmos SDK coin type | -| array.coin | coins | no | sdk.Coins | List of Cosmos SDK coin types | +For detailed type information use ignite scaffold type --help "Index" indicates whether the type can be used as an index in "ignite scaffold map". diff --git a/ignite/cmd/scaffold_map.go b/ignite/cmd/scaffold_map.go index a739e4f794..5d20479deb 100644 --- a/ignite/cmd/scaffold_map.go +++ b/ignite/cmd/scaffold_map.go @@ -26,7 +26,7 @@ incrementing integer, whereas "map" values are indexed by a user-provided value Let's use the same blog post example: - ignite scaffold map post title body + ignite scaffold map post title body:string This command scaffolds a "Post" type and CRUD functionality to create, read, updated, and delete posts. However, when creating a new post with your chain's @@ -54,6 +54,8 @@ product values that have the same category but are using different GUIDs. Since the behavior of "list" and "map" scaffolding is very similar, you can use the "--no-message", "--module", "--signer" flags as well as the colon syntax for custom types. + +For detailed type information use ignite scaffold type --help `, Args: cobra.MinimumNArgs(1), PreRunE: migrationPreRunHandler, diff --git a/ignite/cmd/scaffold_message.go b/ignite/cmd/scaffold_message.go index c980ec6259..931960b69c 100644 --- a/ignite/cmd/scaffold_message.go +++ b/ignite/cmd/scaffold_message.go @@ -13,7 +13,7 @@ const flagSigner = "signer" // NewScaffoldMessage returns the command to scaffold messages. func NewScaffoldMessage() *cobra.Command { c := &cobra.Command{ - Use: "message [name] [field1] [field2] ...", + Use: "message [name] [field1:type1] [field2:type2] ...", Short: "Message to perform state transition on the blockchain", Long: `Message scaffolding is useful for quickly adding functionality to your blockchain to handle specific Cosmos SDK messages. @@ -38,6 +38,8 @@ The command above will create a new message MsgAddPool with three fields: amount (in tokens), denom (a string), and active (a boolean). The message will be added to the "dex" module. +For detailed type information use ignite scaffold type --help + By default, the message is defined as a proto message in the "proto/{app}/{module}/tx.proto" and registered in the "Msg" service. A CLI command to create and broadcast a transaction with MsgAddPool is created in the module's diff --git a/ignite/cmd/scaffold_query.go b/ignite/cmd/scaffold_query.go index 6f6cb4bcf3..4c39653336 100644 --- a/ignite/cmd/scaffold_query.go +++ b/ignite/cmd/scaffold_query.go @@ -17,8 +17,11 @@ const ( // NewScaffoldQuery command creates a new type command to scaffold queries. func NewScaffoldQuery() *cobra.Command { c := &cobra.Command{ - Use: "query [name] [request_field1] [request_field2] ...", - Short: "Query for fetching data from a blockchain", + Use: "query [name] [field1:type1] [field2:type2] ...", + Short: "Query for fetching data from a blockchain", + Long: `Query for fetching data from a blockchain. + +For detailed type information use ignite scaffold type --help.`, Args: cobra.MinimumNArgs(1), PreRunE: migrationPreRunHandler, RunE: queryHandler, diff --git a/ignite/cmd/scaffold_single.go b/ignite/cmd/scaffold_single.go index 26fce37f17..1243b34f39 100644 --- a/ignite/cmd/scaffold_single.go +++ b/ignite/cmd/scaffold_single.go @@ -9,8 +9,12 @@ import ( // NewScaffoldSingle returns a new command to scaffold a singleton. func NewScaffoldSingle() *cobra.Command { c := &cobra.Command{ - Use: "single NAME [field]...", - Short: "CRUD for data stored in a single location", + Use: "single NAME [field:type]...", + Short: "CRUD for data stored in a single location", + Long: `CRUD for data stored in a single location. + +For detailed type information use ignite scaffold type --help.`, + Example: " ignite scaffold single todo-single title:string done:bool", Args: cobra.MinimumNArgs(1), PreRunE: migrationPreRunHandler, RunE: scaffoldSingleHandler, diff --git a/ignite/cmd/scaffold_type.go b/ignite/cmd/scaffold_type.go index 1fcdaceeb1..f8178379b9 100644 --- a/ignite/cmd/scaffold_type.go +++ b/ignite/cmd/scaffold_type.go @@ -1,6 +1,8 @@ package ignitecmd import ( + "fmt" + "github.com/spf13/cobra" "github.com/ignite/cli/ignite/services/scaffolder" @@ -9,8 +11,10 @@ import ( // NewScaffoldType returns a new command to scaffold a type. func NewScaffoldType() *cobra.Command { c := &cobra.Command{ - Use: "type NAME [field]...", + Use: "type NAME [field:type] ...", Short: "Type definition", + Long: fmt.Sprintf("Type information\n%s\n", supportFieldTypes), + Example: " ignite scaffold type todo-item priority:int desc:string tags:array.string done:bool", Args: cobra.MinimumNArgs(1), PreRunE: migrationPreRunHandler, RunE: scaffoldTypeHandler,