Skip to content

Commit 2e41a8a

Browse files
committed
Merge branch 'main' into julien/fix
2 parents 55ff0c9 + 91369df commit 2e41a8a

File tree

20 files changed

+572
-109
lines changed

20 files changed

+572
-109
lines changed

changelog.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,20 @@
22

33
## Unreleased
44

5+
### Features
6+
7+
- [#4786](https://github.com/ignite/cli/pull/4786) Add all types to the documentation and disclaimer for multiple coin types.
8+
59
## [`v29.2.1`](https://github.com/ignite/cli/releases/tag/v29.2.1)
610

711
### Changes
812

913
- [#4780](https://github.com/ignite/cli/pull/4780) Fallback to local generation when possible in `generate ts-client` command.
14+
- [#4779](https://github.com/ignite/cli/pull/4779) Do not re-gen openapi spec each time the `ts-client` or the `composables` are generated.
15+
16+
### Fixes
17+
18+
- [#4779](https://github.com/ignite/cli/pull/4779) Find proto dir in non conventional repo structure.
1019

1120
## [`v29.2.0`](https://github.com/ignite/cli/releases/tag/v29.2.0)
1221

docs/docs/03-CLI-Commands/01-cli-commands.md

Lines changed: 61 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2041,19 +2041,28 @@ Type definition
20412041

20422042
Type information
20432043

2044-
Currently supports:
2045-
2046-
| Type | Alias | Index | Code Type | Description |
2047-
|--------------|---------|-------|-----------|---------------------------------|
2048-
| string | - | yes | string | Text type |
2049-
| array.string | strings | no | []string | List of text type |
2050-
| bool | - | yes | bool | Boolean type |
2051-
| int | - | yes | int64 | Integer type |
2052-
| array.int | ints | no | []int64 | List of integers types |
2053-
| uint | - | yes | uint64 | Unsigned integer type |
2054-
| array.uint | uints | no | []uint64 | List of unsigned integers types |
2055-
| coin | - | no | sdk.Coin | Cosmos SDK coin type |
2056-
| array.coin | coins | no | sdk.Coins | List of Cosmos SDK coin types |
2044+
Types Usage
2045+
address use '<FIELD_NAME>:address' to scaffold string types (eg: cosmos1abcdefghijklmnopqrstuvwxyz0123456).
2046+
array.coin use '<FIELD_NAME>:array.coin' to scaffold sdk.Coins types (eg: 20stake). Disclaimer: Only one `coins` or `dec.coins` field can accept multiple CLI values per command due to AutoCLI limitations.
2047+
array.dec.coin use '<FIELD_NAME>:array.dec.coin' to scaffold sdk.DecCoins types (eg: 20000002stake). Disclaimer: Only one `coins` or `dec.coins` field can accept multiple CLI values per command due to AutoCLI limitations.
2048+
array.int use '<FIELD_NAME>:array.int' to scaffold []int64 types (eg: 5,4,3,2,1).
2049+
array.string use '<FIELD_NAME>:array.string' to scaffold []string types (eg: abc,xyz).
2050+
array.uint use '<FIELD_NAME>:array.uint' to scaffold []uint64 types (eg: 13,26,31,40).
2051+
bool use '<FIELD_NAME>:bool' to scaffold bool types (eg: true).
2052+
bytes use '<FIELD_NAME>:bytes' to scaffold []byte types (eg: 3,2,3,5).
2053+
coin use '<FIELD_NAME>:coin' to scaffold sdk.Coin types (eg: 10token).
2054+
coins use '<FIELD_NAME>:array.coin' to scaffold sdk.Coins types (eg: 20stake). Disclaimer: Only one `coins` or `dec.coins` field can accept multiple CLI values per command due to AutoCLI limitations.
2055+
custom use the custom type to scaffold already created chain types.
2056+
dec.coin use '<FIELD_NAME>:dec.coin' to scaffold sdk.DecCoin types (eg: 100001token).
2057+
dec.coins use '<FIELD_NAME>:array.dec.coin' to scaffold sdk.DecCoins types (eg: 20000002stake). Disclaimer: Only one `coins` or `dec.coins` field can accept multiple CLI values per command due to AutoCLI limitations.
2058+
int use '<FIELD_NAME>:int' to scaffold int64 types (eg: 111).
2059+
int64 use '<FIELD_NAME>:int' to scaffold int64 types (eg: 111).
2060+
ints use '<FIELD_NAME>:array.int' to scaffold []int64 types (eg: 5,4,3,2,1).
2061+
string use '<FIELD_NAME>:string' to scaffold string types (eg: xyz).
2062+
strings use '<FIELD_NAME>:array.string' to scaffold []string types (eg: abc,xyz).
2063+
uint use '<FIELD_NAME>:uint' to scaffold uint64 types (eg: 111).
2064+
uint64 use '<FIELD_NAME>:uint' to scaffold uint64 types (eg: 111).
2065+
uints use '<FIELD_NAME>:array.uint' to scaffold []uint64 types (eg: 13,26,31,40).
20572066

20582067
Field Usage:
20592068
- fieldName
@@ -2312,3 +2321,42 @@ ignite version [flags]
23122321

23132322
* [ignite](#ignite) - Ignite CLI offers everything you need to scaffold, test, build, and launch your blockchain
23142323

2324+
# Scaffold Type
2325+
2326+
Ignites provides a set of scaffold types that can be used to generate code for your application.
2327+
These types are used in the `ignite scaffold` command.
2328+
2329+
## Available Scaffold Types
2330+
2331+
| Type | Usage |
2332+
| --- | --- |
2333+
| address | use '<FIELD_NAME>:address' to scaffold string types (eg: cosmos1abcdefghijklmnopqrstuvwxyz0123456). |
2334+
| array.coin | use '<FIELD_NAME>:array.coin' to scaffold sdk.Coins types (eg: 20stake). Disclaimer: Only one `coins` or `dec.coins` field can accept multiple CLI values per command due to AutoCLI limitations. |
2335+
| array.dec.coin | use '<FIELD_NAME>:array.dec.coin' to scaffold sdk.DecCoins types (eg: 20000002stake). Disclaimer: Only one `coins` or `dec.coins` field can accept multiple CLI values per command due to AutoCLI limitations. |
2336+
| array.int | use '<FIELD_NAME>:array.int' to scaffold []int64 types (eg: 5,4,3,2,1). |
2337+
| array.string | use '<FIELD_NAME>:array.string' to scaffold []string types (eg: abc,xyz). |
2338+
| array.uint | use '<FIELD_NAME>:array.uint' to scaffold []uint64 types (eg: 13,26,31,40). |
2339+
| bool | use '<FIELD_NAME>:bool' to scaffold bool types (eg: true). |
2340+
| bytes | use '<FIELD_NAME>:bytes' to scaffold []byte types (eg: 3,2,3,5). |
2341+
| coin | use '<FIELD_NAME>:coin' to scaffold sdk.Coin types (eg: 10token). |
2342+
| coins | use '<FIELD_NAME>:array.coin' to scaffold sdk.Coins types (eg: 20stake). Disclaimer: Only one `coins` or `dec.coins` field can accept multiple CLI values per command due to AutoCLI limitations. |
2343+
| custom | use the custom type to scaffold already created chain types. |
2344+
| dec.coin | use '<FIELD_NAME>:dec.coin' to scaffold sdk.DecCoin types (eg: 100001token). |
2345+
| dec.coins | use '<FIELD_NAME>:array.dec.coin' to scaffold sdk.DecCoins types (eg: 20000002stake). Disclaimer: Only one `coins` or `dec.coins` field can accept multiple CLI values per command due to AutoCLI limitations. |
2346+
| int | use '<FIELD_NAME>:int' to scaffold int64 types (eg: 111). |
2347+
| int64 | use '<FIELD_NAME>:int' to scaffold int64 types (eg: 111). |
2348+
| ints | use '<FIELD_NAME>:array.int' to scaffold []int64 types (eg: 5,4,3,2,1). |
2349+
| string | use '<FIELD_NAME>:string' to scaffold string types (eg: xyz). |
2350+
| strings | use '<FIELD_NAME>:array.string' to scaffold []string types (eg: abc,xyz). |
2351+
| uint | use '<FIELD_NAME>:uint' to scaffold uint64 types (eg: 111). |
2352+
| uint64 | use '<FIELD_NAME>:uint' to scaffold uint64 types (eg: 111). |
2353+
| uints | use '<FIELD_NAME>:array.uint' to scaffold []uint64 types (eg: 13,26,31,40). |
2354+
2355+
2356+
Field Usage:
2357+
2358+
- fieldName
2359+
- fieldName:fieldType
2360+
2361+
2362+
If no :fieldType, default (string) is used

ignite/cmd/scaffold.go

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@ import (
55
flag "github.com/spf13/pflag"
66

77
"github.com/ignite/cli/v29/ignite/pkg/cliui"
8+
"github.com/ignite/cli/v29/ignite/pkg/cliui/colors"
89
"github.com/ignite/cli/v29/ignite/pkg/cosmosver"
910
"github.com/ignite/cli/v29/ignite/pkg/env"
1011
"github.com/ignite/cli/v29/ignite/pkg/errors"
1112
"github.com/ignite/cli/v29/ignite/pkg/gocmd"
1213
"github.com/ignite/cli/v29/ignite/pkg/xgenny"
1314
"github.com/ignite/cli/v29/ignite/pkg/xgit"
1415
"github.com/ignite/cli/v29/ignite/services/scaffolder"
16+
"github.com/ignite/cli/v29/ignite/templates/field"
1517
"github.com/ignite/cli/v29/ignite/version"
1618
)
1719

@@ -27,28 +29,12 @@ const (
2729
msgCommitPrefix = "Your project changes have not been committed.\nTo enable reverting to your current state, commit your saved changes."
2830
msgCommitPrompt = "Do you want to proceed without committing your saved changes"
2931

30-
statusScaffolding = "Scaffolding..."
31-
32-
supportFieldTypes = `
33-
Currently supports:
34-
35-
| Type | Alias | Index | Code Type | Description |
36-
|--------------|---------|-------|-----------|---------------------------------|
37-
| string | - | yes | string | Text type |
38-
| array.string | strings | no | []string | List of text type |
39-
| bool | - | yes | bool | Boolean type |
40-
| int | - | yes | int64 | Integer type |
41-
| array.int | ints | no | []int64 | List of integers types |
42-
| uint | - | yes | uint64 | Unsigned integer type |
43-
| array.uint | uints | no | []uint64 | List of unsigned integers types |
44-
| coin | - | no | sdk.Coin | Cosmos SDK coin type |
45-
| array.coin | coins | no | sdk.Coins | List of Cosmos SDK coin types |
46-
47-
Field Usage:
48-
- fieldName
49-
- fieldName:fieldType
50-
51-
If no :fieldType, default (string) is used
32+
statusScaffolding = "Scaffolding..."
33+
multipleCoinDisclaimer = `**Disclaimer**
34+
The 'coins' and 'dec.coins' argument types require special attention when used in CLI commands.
35+
Due to current limitations in the AutoCLI, only one variadic (slice) argument is supported per command.
36+
If a message contains more than one field of type 'coins' or 'dec.coins', only the last one will accept multiple values via the CLI.
37+
For the best user experience, manual command handling or scaffolding is recommended when working with messages containing multiple 'coins' or 'dec.coins' fields.
5238
`
5339
)
5440

@@ -220,6 +206,18 @@ func scaffoldType(
220206
)
221207
defer session.End()
222208

209+
if !withoutMessage {
210+
hasMultipleCoinSlice, err := field.MultipleCoins(fields)
211+
if err != nil {
212+
return err
213+
}
214+
if hasMultipleCoinSlice {
215+
session.PauseSpinner()
216+
_ = session.Print(colors.Info(multipleCoinDisclaimer))
217+
session.StartSpinner(statusScaffolding)
218+
}
219+
}
220+
223221
cfg, _, err := getChainConfig(cmd)
224222
if err != nil {
225223
return err

ignite/cmd/scaffold_message.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@ import (
44
"github.com/spf13/cobra"
55

66
"github.com/ignite/cli/v29/ignite/pkg/cliui"
7+
"github.com/ignite/cli/v29/ignite/pkg/cliui/colors"
78
"github.com/ignite/cli/v29/ignite/pkg/xgenny"
89
"github.com/ignite/cli/v29/ignite/services/scaffolder"
10+
"github.com/ignite/cli/v29/ignite/templates/field"
911
)
1012

1113
const flagSigner = "signer"
@@ -95,6 +97,16 @@ func messageHandler(cmd *cobra.Command, args []string) error {
9597
)
9698
defer session.End()
9799

100+
hasMultipleCoinSlice, err := field.MultipleCoins(resFields)
101+
if err != nil {
102+
return err
103+
}
104+
if hasMultipleCoinSlice {
105+
session.PauseSpinner()
106+
_ = session.Print(colors.Info(multipleCoinDisclaimer))
107+
session.StartSpinner(statusScaffolding)
108+
}
109+
98110
cfg, _, err := getChainConfig(cmd)
99111
if err != nil {
100112
return err

ignite/cmd/scaffold_type.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,23 @@ package ignitecmd
22

33
import (
44
"fmt"
5+
"strings"
56

67
"github.com/spf13/cobra"
78

89
"github.com/ignite/cli/v29/ignite/services/scaffolder"
10+
"github.com/ignite/cli/v29/ignite/templates/field/datatype"
911
)
1012

1113
// NewScaffoldType returns a new command to scaffold a type.
1214
func NewScaffoldType() *cobra.Command {
15+
b := strings.Builder{}
16+
_ = datatype.PrintScaffoldTypeList(&b)
17+
1318
c := &cobra.Command{
1419
Use: "type NAME [field:type] ...",
1520
Short: "Type definition",
16-
Long: fmt.Sprintf("Type information\n%s\n", supportFieldTypes),
21+
Long: fmt.Sprintf("Type information\n\n%s\n", b.String()),
1722
Example: " ignite scaffold type todo-item priority:int desc:string tags:array.string done:bool",
1823
Args: cobra.MinimumNArgs(1),
1924
PreRunE: migrationPreRunHandler,

ignite/cmd/scaffold_type_list.go

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package ignitecmd
22

33
import (
4-
"sort"
5-
64
"github.com/spf13/cobra"
75

86
"github.com/ignite/cli/v29/ignite/pkg/cliui"
@@ -16,28 +14,16 @@ func NewScaffoldTypeList() *cobra.Command {
1614
Short: "List scaffold types",
1715
Long: "List all available scaffold types",
1816
Args: cobra.NoArgs,
19-
RunE: scaffoldTypeListHandler,
17+
RunE: func(cmd *cobra.Command, _ []string) error {
18+
session := cliui.New(
19+
cliui.StartSpinnerWithText("printing..."),
20+
cliui.WithoutUserInteraction(getYes(cmd)),
21+
)
22+
defer session.End()
23+
session.StopSpinner()
24+
return datatype.PrintScaffoldTypeList(cmd.OutOrStdout())
25+
},
2026
}
2127

2228
return c
2329
}
24-
25-
func scaffoldTypeListHandler(cmd *cobra.Command, _ []string) error {
26-
session := cliui.New(
27-
cliui.StartSpinnerWithText("printing..."),
28-
cliui.WithoutUserInteraction(getYes(cmd)),
29-
)
30-
defer session.End()
31-
32-
supported := datatype.SupportedTypes()
33-
entries := make([][]string, 0, len(supported))
34-
for name, usage := range supported {
35-
entries = append(entries, []string{name, usage})
36-
}
37-
38-
sort.Slice(entries, func(i, j int) bool {
39-
return entries[i][0] < entries[j][0]
40-
})
41-
42-
return session.PrintTable([]string{"types", "usage"}, entries...)
43-
}

ignite/internal/tools/gen-cli-docs/main.go

Lines changed: 65 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"log"
1212
"os"
1313
"path/filepath"
14+
"sort"
1415
"strings"
1516

1617
"github.com/spf13/cobra"
@@ -20,9 +21,28 @@ import (
2021
pluginsconfig "github.com/ignite/cli/v29/ignite/config/plugins"
2122
"github.com/ignite/cli/v29/ignite/pkg/env"
2223
"github.com/ignite/cli/v29/ignite/services/plugin"
24+
"github.com/ignite/cli/v29/ignite/templates/field/datatype"
2325
)
2426

2527
const (
28+
scaffoldTypeFooter = `
29+
30+
Field Usage:
31+
32+
- fieldName
33+
- fieldName:fieldType
34+
35+
36+
If no :fieldType, default (string) is used
37+
`
38+
scaffoldTypeHead = `# Scaffold Type
39+
40+
Ignites provides a set of scaffold types that can be used to generate code for your application.
41+
These types are used in the ` + "`ignite scaffold`" + ` command.
42+
43+
## Available Scaffold Types
44+
45+
`
2646
head = `---
2747
description: Ignite CLI docs.
2848
---
@@ -67,7 +87,8 @@ func run() error {
6787
return err
6888
}
6989
defer cleanUp()
70-
cmd.Flags().String(outFlag, ".", ".md file path to place Ignite CLI docs inside")
90+
91+
cmd.Flags().String(outFlag, "output.md", ".md file path to place Ignite CLI docs inside")
7192
if err := cmd.Flags().MarkHidden(outFlag); err != nil {
7293
return err
7394
}
@@ -83,10 +104,10 @@ func run() error {
83104
return nil
84105
}
85106

86-
return generate(cmd, outPath)
107+
return generateUsage(cmd, outPath)
87108
}
88109

89-
func generate(cmd *cobra.Command, outPath string) error {
110+
func generateUsage(cmd *cobra.Command, outPath string) error {
90111
if err := os.MkdirAll(filepath.Dir(outPath), 0o755); err != nil {
91112
return err
92113
}
@@ -100,7 +121,47 @@ func generate(cmd *cobra.Command, outPath string) error {
100121
return err
101122
}
102123

103-
return generateCmd(cmd, f)
124+
if err := generateCmd(cmd, f); err != nil {
125+
return err
126+
}
127+
128+
return generateScaffoldTypes(f)
129+
}
130+
131+
func generateScaffoldTypes(w io.Writer) error {
132+
if _, err := fmt.Fprint(w, scaffoldTypeHead); err != nil {
133+
return err
134+
}
135+
136+
supported := datatype.SupportedTypes()
137+
entries := make([][]string, 0, len(supported))
138+
for name, usage := range supported {
139+
entries = append(entries, []string{name, usage})
140+
}
141+
142+
sort.Slice(entries, func(i, j int) bool {
143+
return entries[i][0] < entries[j][0]
144+
})
145+
146+
// Write table header
147+
if _, err := fmt.Fprintf(w, "| Type | Usage |\n"); err != nil {
148+
return err
149+
}
150+
if _, err := fmt.Fprintf(w, "| --- | --- |\n"); err != nil {
151+
return err
152+
}
153+
154+
// Write table rows
155+
for _, entry := range entries {
156+
if _, err := fmt.Fprintf(w, "| %s | %s |\n", entry[0], entry[1]); err != nil {
157+
return err
158+
}
159+
}
160+
161+
if _, err := fmt.Fprint(w, scaffoldTypeFooter); err != nil {
162+
return err
163+
}
164+
return nil
104165
}
105166

106167
func generateCmd(cmd *cobra.Command, w io.Writer) error {

0 commit comments

Comments
 (0)