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: improve scaffold query --help #3349

Merged
merged 23 commits into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
ac60e27
implemented issue #3346
AndrewDonelson Dec 30, 2022
2649338
update changelog
AndrewDonelson Dec 30, 2022
e7d0d10
Merge branch 'main' into feat/issue_3346
Dec 30, 2022
c612c3c
update single supported type table
AndrewDonelson Dec 30, 2022
d48db62
Merge branch 'main' into feat/issue_3346_updated
Pantani May 22, 2023
a42a9b9
Merge branch 'main' into feat/issue_3346_updated
Pantani May 22, 2023
d9bc1d4
Merge branch 'main' into feat/issue_3346_updated
Pantani May 22, 2023
349e6c6
Merge branch 'main' into feat/issue_3346_updated
Pantani May 23, 2023
1615ec0
Merge branch 'main' into feat/issue_3346_updated
Pantani May 25, 2023
0ff513e
Merge branch 'main' into feat/issue_3346_updated
Pantani Jul 19, 2023
0949a6e
Merge branch 'main' into feat/issue_3346_updated
Pantani Aug 10, 2023
ab2514a
Merge branch 'main' into feat/issue_3346_updated
Pantani Aug 28, 2023
be093e6
Merge branch 'main' into feat/issue_3346_updated
Pantani Oct 16, 2023
c699e7f
Merge branch 'main' into feat/issue_3346_updated
Pantani Oct 16, 2023
59e2827
Update app.go
Ehsan-saradar Oct 17, 2023
2e34c61
Enhance cli docs
Ehsan-saradar Oct 18, 2023
0ec6c59
Revert "Update app.go"
Ehsan-saradar Oct 18, 2023
9c7ce28
Merge branch 'main' into feat/issue_3346_updated
Pantani Oct 18, 2023
48ddcac
Update ignite/cmd/scaffold_single.go
Ehsan-saradar Oct 18, 2023
55f1bdc
Update ignite/cmd/scaffold_type.go
Ehsan-saradar Oct 18, 2023
3b58b6e
add example
Ehsan-saradar Oct 18, 2023
a3460aa
Merge branch 'main' into feat/issue_3346_updated
Pantani Oct 18, 2023
4575c6f
Merge branch 'main' into feat/issue_3346_updated
Pantani Oct 19, 2023
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 @@ -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
Expand Down
22 changes: 22 additions & 0 deletions ignite/cmd/scaffold.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
`
Ehsan-saradar marked this conversation as resolved.
Show resolved Hide resolved
)

// NewScaffold returns a command that groups scaffolding related sub commands.
Expand Down
14 changes: 1 addition & 13 deletions ignite/cmd/scaffold_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 "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
Ehsan-saradar marked this conversation as resolved.
Show resolved Hide resolved

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: migrationPreRunHandler,
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: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.
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
7 changes: 5 additions & 2 deletions ignite/cmd/scaffold_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 6 additions & 2 deletions ignite/cmd/scaffold_single.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you also add an example to the Example parameter?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, also do you think we need to add Example for other scaffold commands?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can only cover these query commands in this PR and others later, wdyt?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good to me

PreRunE: migrationPreRunHandler,
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: migrationPreRunHandler,
RunE: scaffoldTypeHandler,
Expand Down