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

feat: set positional args for delete commands and scaffolded autocli config #3822

Merged
merged 9 commits into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from 7 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
12 changes: 8 additions & 4 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,21 @@

## Unreleased

### Features

- [#3830](https://github.com/ignite/cli/pull/3830) Remove gRPC info from Ignite Apps errors

### Changes

- [#3822](https://github.com/ignite/cli/pull/3822) Improve default scaffolded AutoCLI config

### Fixes

- [#3827](https://github.com/ignite/cli/pull/3827) Change ignite apps to be able to run in any directory
- [#3831](https://github.com/ignite/cli/pull/3831) Correct ignite app gRPC server stop memory issue
- [#3825](https://github.com/ignite/cli/pull/3825) Fix a minor Keplr type-checking bug in TS client
- [#3836](https://github.com/ignite/cli/pull/3836) Add missing IBC commands for scaffolded chain

### Features

- [#3830](https://github.com/ignite/cli/pull/3830) Remove gRPC info from Ignite Apps errors

## [`v28.0.0`](https://github.com/ignite/cli/releases/tag/v28.0.0)

### Features
Expand Down
13 changes: 8 additions & 5 deletions ignite/templates/typed/list/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -336,27 +336,29 @@
return err
}

var positionalArgs string
var positionalArgs, positionalArgsStr string

Check warning on line 339 in ignite/templates/typed/list/list.go

View check run for this annotation

Codecov / codecov/patch

ignite/templates/typed/list/list.go#L339

Added line #L339 was not covered by tests
for _, field := range opts.Fields {
positionalArgs += fmt.Sprintf(`{ProtoField: "%s"}, `, field.ProtoFieldName())
positionalArgsStr += fmt.Sprintf("[%s] ", field.ProtoFieldName())

Check warning on line 342 in ignite/templates/typed/list/list.go

View check run for this annotation

Codecov / codecov/patch

ignite/templates/typed/list/list.go#L342

Added line #L342 was not covered by tests
}

template := `{
RpcMethod: "Create%[2]v",
Use: "create-%[3]v",
Use: "create-%[3]v %[6]s",

Check warning on line 347 in ignite/templates/typed/list/list.go

View check run for this annotation

Codecov / codecov/patch

ignite/templates/typed/list/list.go#L347

Added line #L347 was not covered by tests
Short: "Create %[4]v",
PositionalArgs: []*autocliv1.PositionalArgDescriptor{%[5]s},
},
{
RpcMethod: "Update%[2]v",
Use: "update-%[3]v",
Use: "update-%[3]v [id] %[6]s",

Check warning on line 353 in ignite/templates/typed/list/list.go

View check run for this annotation

Codecov / codecov/patch

ignite/templates/typed/list/list.go#L353

Added line #L353 was not covered by tests
Short: "Update %[4]v",
PositionalArgs: []*autocliv1.PositionalArgDescriptor{%[5]s},
PositionalArgs: []*autocliv1.PositionalArgDescriptor{{ProtoField: "id"}, %[5]s},

Check warning on line 355 in ignite/templates/typed/list/list.go

View check run for this annotation

Codecov / codecov/patch

ignite/templates/typed/list/list.go#L355

Added line #L355 was not covered by tests
},
{
RpcMethod: "Delete%[2]v",
Use: "delete-%[3]v",
Use: "delete-%[3]v [id]",

Check warning on line 359 in ignite/templates/typed/list/list.go

View check run for this annotation

Codecov / codecov/patch

ignite/templates/typed/list/list.go#L359

Added line #L359 was not covered by tests
Short: "Delete %[4]v",
PositionalArgs: []*autocliv1.PositionalArgDescriptor{{ProtoField: "id"}},

Check warning on line 361 in ignite/templates/typed/list/list.go

View check run for this annotation

Codecov / codecov/patch

ignite/templates/typed/list/list.go#L361

Added line #L361 was not covered by tests
},
%[1]v`

Expand All @@ -367,6 +369,7 @@
opts.TypeName.Kebab,
opts.TypeName.Original,
strings.TrimSpace(positionalArgs),
strings.TrimSpace(positionalArgsStr),

Check warning on line 372 in ignite/templates/typed/list/list.go

View check run for this annotation

Codecov / codecov/patch

ignite/templates/typed/list/list.go#L372

Added line #L372 was not covered by tests
)

content := replacer.Replace(f.String(), typed.PlaceholderAutoCLITx, replacement)
Expand Down
19 changes: 14 additions & 5 deletions ignite/templates/typed/map/map.go
Original file line number Diff line number Diff line change
Expand Up @@ -627,30 +627,36 @@
return err
}

var positionalArgs string
var positionalArgs, positionalArgsStr string
var indexes, indexesStr string

Check warning on line 631 in ignite/templates/typed/map/map.go

View check run for this annotation

Codecov / codecov/patch

ignite/templates/typed/map/map.go#L630-L631

Added lines #L630 - L631 were not covered by tests
for _, field := range opts.Fields {
positionalArgs += fmt.Sprintf(`{ProtoField: "%s"}, `, field.ProtoFieldName())
positionalArgsStr += fmt.Sprintf("[%s] ", field.ProtoFieldName())

Check warning on line 634 in ignite/templates/typed/map/map.go

View check run for this annotation

Codecov / codecov/patch

ignite/templates/typed/map/map.go#L634

Added line #L634 was not covered by tests
}
for _, field := range opts.Indexes {
positionalArgs += fmt.Sprintf(`{ProtoField: "%s"}, `, field.ProtoFieldName())
indexes += fmt.Sprintf(`{ProtoField: "%s"}, `, field.ProtoFieldName())
indexesStr += fmt.Sprintf("[%s] ", field.ProtoFieldName())

Check warning on line 638 in ignite/templates/typed/map/map.go

View check run for this annotation

Codecov / codecov/patch

ignite/templates/typed/map/map.go#L637-L638

Added lines #L637 - L638 were not covered by tests
}
positionalArgs = indexes + positionalArgs
positionalArgsStr = indexesStr + positionalArgsStr

Check warning on line 641 in ignite/templates/typed/map/map.go

View check run for this annotation

Codecov / codecov/patch

ignite/templates/typed/map/map.go#L640-L641

Added lines #L640 - L641 were not covered by tests

template := `{
RpcMethod: "Create%[2]v",
Use: "create-%[3]v",
Use: "create-%[3]v %[6]s",

Check warning on line 645 in ignite/templates/typed/map/map.go

View check run for this annotation

Codecov / codecov/patch

ignite/templates/typed/map/map.go#L645

Added line #L645 was not covered by tests
Short: "Create a new %[4]v",
PositionalArgs: []*autocliv1.PositionalArgDescriptor{%[5]s},
},
{
RpcMethod: "Update%[2]v",
Use: "update-%[3]v",
Use: "update-%[3]v %[6]s",

Check warning on line 651 in ignite/templates/typed/map/map.go

View check run for this annotation

Codecov / codecov/patch

ignite/templates/typed/map/map.go#L651

Added line #L651 was not covered by tests
Short: "Update %[4]v",
PositionalArgs: []*autocliv1.PositionalArgDescriptor{%[5]s},
},
{
RpcMethod: "Delete%[2]v",
Use: "delete-%[3]v",
Use: "delete-%[3]v %[8]s",

Check warning on line 657 in ignite/templates/typed/map/map.go

View check run for this annotation

Codecov / codecov/patch

ignite/templates/typed/map/map.go#L657

Added line #L657 was not covered by tests
Short: "Delete %[4]v",
PositionalArgs: []*autocliv1.PositionalArgDescriptor{%[7]s},

Check warning on line 659 in ignite/templates/typed/map/map.go

View check run for this annotation

Codecov / codecov/patch

ignite/templates/typed/map/map.go#L659

Added line #L659 was not covered by tests
},
%[1]v`

Expand All @@ -661,6 +667,9 @@
opts.TypeName.Kebab,
opts.TypeName.Original,
strings.TrimSpace(positionalArgs),
strings.TrimSpace(positionalArgsStr),
strings.TrimSpace(indexes),
strings.TrimSpace(indexesStr),

Check warning on line 672 in ignite/templates/typed/map/map.go

View check run for this annotation

Codecov / codecov/patch

ignite/templates/typed/map/map.go#L670-L672

Added lines #L670 - L672 were not covered by tests
)

content := replacer.Replace(f.String(), typed.PlaceholderAutoCLITx, replacement)
Expand Down
8 changes: 5 additions & 3 deletions ignite/templates/typed/singleton/singleton.go
Original file line number Diff line number Diff line change
Expand Up @@ -460,20 +460,21 @@
return err
}

var positionalArgs string
var positionalArgs, positionalArgsStr string

Check warning on line 463 in ignite/templates/typed/singleton/singleton.go

View check run for this annotation

Codecov / codecov/patch

ignite/templates/typed/singleton/singleton.go#L463

Added line #L463 was not covered by tests
for _, field := range opts.Fields {
positionalArgs += fmt.Sprintf(`{ProtoField: "%s"}, `, field.ProtoFieldName())
positionalArgsStr += fmt.Sprintf("[%s] ", field.ProtoFieldName())

Check warning on line 466 in ignite/templates/typed/singleton/singleton.go

View check run for this annotation

Codecov / codecov/patch

ignite/templates/typed/singleton/singleton.go#L466

Added line #L466 was not covered by tests
}

template := `{
RpcMethod: "Create%[2]v",
Use: "create-%[3]v",
Use: "create-%[3]v %[6]s",

Check warning on line 471 in ignite/templates/typed/singleton/singleton.go

View check run for this annotation

Codecov / codecov/patch

ignite/templates/typed/singleton/singleton.go#L471

Added line #L471 was not covered by tests
Short: "Create %[4]v",
PositionalArgs: []*autocliv1.PositionalArgDescriptor{%[5]s},
},
{
RpcMethod: "Update%[2]v",
Use: "update-%[3]v",
Use: "update-%[3]v %[6]s",

Check warning on line 477 in ignite/templates/typed/singleton/singleton.go

View check run for this annotation

Codecov / codecov/patch

ignite/templates/typed/singleton/singleton.go#L477

Added line #L477 was not covered by tests
Short: "Update %[4]v",
PositionalArgs: []*autocliv1.PositionalArgDescriptor{%[5]s},
},
Expand All @@ -491,6 +492,7 @@
opts.TypeName.Kebab,
opts.TypeName.Original,
strings.TrimSpace(positionalArgs),
strings.TrimSpace(positionalArgsStr),

Check warning on line 495 in ignite/templates/typed/singleton/singleton.go

View check run for this annotation

Codecov / codecov/patch

ignite/templates/typed/singleton/singleton.go#L495

Added line #L495 was not covered by tests
)

content := replacer.Replace(f.String(), typed.PlaceholderAutoCLITx, replacement)
Expand Down
Loading