* 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>
41 lines
709 B
Go
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"
|
|
}
|