diff --git a/client/v2/CHANGELOG.md b/client/v2/CHANGELOG.md index a7e8105b134b..dfd4b8cfb213 100644 --- a/client/v2/CHANGELOG.md +++ b/client/v2/CHANGELOG.md @@ -43,6 +43,10 @@ Ref: https://keepachangelog.com/en/1.0.0/ * [#18626](https://github.com/cosmos/cosmos-sdk/pull/18626) Support for off-chain signing and verification of a file. * [#18461](https://github.com/cosmos/cosmos-sdk/pull/18461) Support governance proposals. +### Improvements + +* [#21936](https://github.com/cosmos/cosmos-sdk/pull/21936) Print possible enum values in error message after an invalid input was provided. + ### API Breaking Changes * [#17709](https://github.com/cosmos/cosmos-sdk/pull/17709) Address codecs have been removed from `autocli.AppOptions` and `flag.Builder`. Instead client/v2 uses the address codecs present in the context (introduced in [#17503](https://github.com/cosmos/cosmos-sdk/pull/17503)). diff --git a/client/v2/autocli/flag/enum.go b/client/v2/autocli/flag/enum.go index 72b27528a9a5..db3f57627511 100644 --- a/client/v2/autocli/flag/enum.go +++ b/client/v2/autocli/flag/enum.go @@ -58,7 +58,12 @@ func (e enumValue) String() string { func (e *enumValue) Set(s string) error { valDesc, ok := e.valMap[s] if !ok { - return fmt.Errorf("%s is not a valid value for enum %s", s, e.enum.FullName()) + var validValues []string + for k := range e.valMap { + validValues = append(validValues, k) + } + + return fmt.Errorf("%s is not a valid value for enum %s. Valid values are: %s", s, e.enum.FullName(), strings.Join(validValues, ", ")) } e.value = valDesc.Number() return nil