cosmos-sdk/client/v2/cli/flag/address.go
Aaron Craelius 1c8a2d9069
feat(cli): dynamically generate query CLI commands (#11725)
* WIP on auto-generating CLi

* WIP

* WIP

* WIP

* add pagination.go

* handle more flag types

* WIP on refactoring

* WIP

* working tests

* add docs

* echo all flags

* add repeated tests

* remove comment

* fix compositeListValue issue

Co-authored-by: Anil Kumar Kammari <anil@vitwit.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-04-27 18:24:42 -04:00

41 lines
709 B
Go

package flag
import (
"context"
"github.com/spf13/pflag"
"google.golang.org/protobuf/reflect/protoreflect"
)
type addressStringType struct{}
func (a addressStringType) NewValue(_ context.Context, _ *Builder) pflag.Value {
return &addressValue{}
}
func (a addressStringType) DefaultValue() string {
return ""
}
type addressValue struct {
value string
}
func (a addressValue) Get() protoreflect.Value {
return protoreflect.ValueOfString(a.value)
}
func (a addressValue) String() string {
return a.value
}
func (a *addressValue) Set(s string) error {
a.value = s
// TODO handle bech32 validation
return nil
}
func (a addressValue) Type() string {
return "bech32 account address key name"
}