Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: inline help text for the scaffold query command #3348

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

### Changes

- [#3346](https://github.com/ignite/cli/issues/3346) Improve scaffold query --help
- [#3305](https://github.com/ignite/cli/pull/3305) Bump Cosmos SDK version to `v0.46.7`.
- [#3068](https://github.com/ignite/cli/pull/3068) Add configs to generated TS code for working with JS projects
- [#3071](https://github.com/ignite/cli/pull/3071) Refactor `ignite/templates` package.
Expand Down
22 changes: 22 additions & 0 deletions ignite/cmd/scaffold.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,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.
Expand Down
16 changes: 2 additions & 14 deletions ignite/cmd/scaffold_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ provides the logic to create, read, update, and delete instances of the type.
For example, let's review a command that generates the code to handle a list of
posts and each post has "title" and "body" fields:

ignite scaffold list post title body
ignite scaffold list post title body:string

This provides you with a "Post" type, MsgCreatePost, MsgUpdatePost,
MsgDeletePost and two queries: Post and PostAll. The compiled CLI, let's say the
Expand All @@ -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".
Expand Down
4 changes: 3 additions & 1 deletion ignite/cmd/scaffold_map.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ incrementing integer, whereas "list" 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
Expand Down Expand Up @@ -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: gitChangesConfirmPreRunHandler,
Expand Down
4 changes: 3 additions & 1 deletion ignite/cmd/scaffold_message.go
Original file line number Diff line number Diff line change
Expand Up @@ -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] [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.
Expand All @@ -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
Expand Down
5 changes: 3 additions & 2 deletions ignite/cmd/scaffold_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ 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] [request_field1] [request_field2:field2_type] ...",
Short: "Query for fetching data from a blockchain\n",
Long: "Query for fetching data from a blockchain\nFor detailed type information use ignite scaffold type --help",
Args: cobra.MinimumNArgs(1),
PreRunE: gitChangesConfirmPreRunHandler,
RunE: queryHandler,
Expand Down
1 change: 1 addition & 0 deletions ignite/cmd/scaffold_single.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ func NewScaffoldSingle() *cobra.Command {
c := &cobra.Command{
Use: "single NAME [field]...",
Short: "CRUD for data stored in a single location",
Long: "CRUD for data stored in a single location\nFor detailed type information use ignite scaffold type --help",
Args: cobra.MinimumNArgs(1),
PreRunE: gitChangesConfirmPreRunHandler,
RunE: scaffoldSingleHandler,
Expand Down
6 changes: 5 additions & 1 deletion ignite/cmd/scaffold_type.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package ignitecmd

import (
"fmt"

"github.com/spf13/cobra"

"github.com/ignite/cli/ignite/services/scaffolder"
Expand All @@ -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: gitChangesConfirmPreRunHandler,
RunE: scaffoldTypeHandler,
Expand Down