Skip to content

Commit e0632f4

Browse files
authored
feat: create scaffold type-list command (#4765)
* feat: create `scaffold type-list` command * add changelog * fix wrong custom name * fix lint
1 parent ed595e9 commit e0632f4

File tree

12 files changed

+84
-1
lines changed

12 files changed

+84
-1
lines changed

changelog.md

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

33
## Unreleased
44

5+
### Features
6+
7+
- [#4765](https://github.com/ignite/cli/pull/4765) Create `scaffold type-list` command.
8+
59
### Changes
610

711
- [#4759](https://github.com/ignite/cli/pull/4759) Remove undocumented RPC address override in services chainer.
812
- [#4760](https://github.com/ignite/cli/pull/4760) Bump Cosmos SDK to `v0.53.3`.
913

14+
1015
### Fixes
1116

1217
- [#4757](https://github.com/ignite/cli/pull/4757) Always delete temp folder from open api generation.

ignite/cmd/scaffold.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ with an "--ibc" flag. Note that the default module is not IBC-enabled.
116116
}
117117

118118
c.AddCommand(
119+
NewScaffoldTypeList(),
119120
NewScaffoldChain(),
120121
NewScaffoldModule(),
121122
NewScaffoldList(),

ignite/cmd/scaffold_type_list.go

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package ignitecmd
2+
3+
import (
4+
"sort"
5+
6+
"github.com/spf13/cobra"
7+
8+
"github.com/ignite/cli/v29/ignite/pkg/cliui"
9+
"github.com/ignite/cli/v29/ignite/templates/field/datatype"
10+
)
11+
12+
// NewScaffoldTypeList returns a new command to list all scaffold types.
13+
func NewScaffoldTypeList() *cobra.Command {
14+
c := &cobra.Command{
15+
Use: "type-list",
16+
Short: "List scaffold types",
17+
Long: "List all available scaffold types",
18+
Args: cobra.NoArgs,
19+
RunE: scaffoldTypeListHandler,
20+
}
21+
22+
return c
23+
}
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/templates/field/datatype/address.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111

1212
// DataAddress address (string) data type definition.
1313
var DataAddress = DataType{
14+
Name: Address,
1415
DataType: func(string) string { return "string" },
1516
CollectionsKeyValueName: func(string) string { return "collections.StringKey" },
1617
DefaultTestValue: "cosmos1abcdefghijklmnopqrstuvwxyz0123456",

ignite/templates/field/datatype/bool.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111

1212
// DataBool bool data type definition.
1313
var DataBool = DataType{
14+
Name: Bool,
1415
DataType: func(string) string { return "bool" },
1516
CollectionsKeyValueName: func(string) string { return "collections.BoolKey" },
1617
DefaultTestValue: "true",

ignite/templates/field/datatype/bytes.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111

1212
// DataBytes is a string data type definition.
1313
var DataBytes = DataType{
14+
Name: Bytes,
1415
DataType: func(string) string { return "[]byte" },
1516
CollectionsKeyValueName: func(string) string { return "collections.BytesKey" },
1617
DefaultTestValue: "3,2,3,5",

ignite/templates/field/datatype/coin.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
var (
1313
// DataCoin coin data type definition.
1414
DataCoin = DataType{
15+
Name: Coin,
1516
DataType: func(string) string { return "sdk.Coin" },
1617
CollectionsKeyValueName: func(string) string { return collectionValueComment },
1718
DefaultTestValue: "10token",
@@ -40,6 +41,7 @@ var (
4041

4142
// DataCoinSlice is a coin array data type definition.
4243
DataCoinSlice = DataType{
44+
Name: Coins,
4345
DataType: func(string) string { return "sdk.Coins" },
4446
CollectionsKeyValueName: func(string) string { return collectionValueComment },
4547
DefaultTestValue: "20stake",

ignite/templates/field/datatype/custom.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111

1212
// DataCustom is a custom data type definition.
1313
var DataCustom = DataType{
14+
Name: Custom,
1415
DataType: func(datatype string) string { return fmt.Sprintf("*%s", datatype) },
1516
CollectionsKeyValueName: func(string) string { return collectionValueComment },
1617
DefaultTestValue: "{}",

ignite/templates/field/datatype/int.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
var (
1313
// DataInt is an int data type definition.
1414
DataInt = DataType{
15+
Name: Int,
1516
DataType: func(string) string { return "int64" },
1617
CollectionsKeyValueName: func(string) string { return "collections.Int64Key" },
1718
DefaultTestValue: "111",
@@ -46,6 +47,7 @@ var (
4647

4748
// DataIntSlice is an int array data type definition.
4849
DataIntSlice = DataType{
50+
Name: IntSlice,
4951
DataType: func(string) string { return "[]int64" },
5052
CollectionsKeyValueName: func(string) string { return collectionValueComment },
5153
DefaultTestValue: "5,4,3,2,1",

ignite/templates/field/datatype/string.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
var (
1313
// DataString is a string data type definition.
1414
DataString = DataType{
15+
Name: String,
1516
DataType: func(string) string { return "string" },
1617
CollectionsKeyValueName: func(string) string { return "collections.StringKey" },
1718
DefaultTestValue: "xyz",
@@ -40,6 +41,7 @@ var (
4041

4142
// DataStringSlice is a string array data type definition.
4243
DataStringSlice = DataType{
44+
Name: StringSlice,
4345
DataType: func(string) string { return "[]string" },
4446
CollectionsKeyValueName: func(string) string { return collectionValueComment },
4547
DefaultTestValue: "abc,xyz",

0 commit comments

Comments
 (0)