cosmossdk.io/client/v2@v2.0.0-beta.1/autocli/flag/interface.go (about)

     1  package flag
     2  
     3  import (
     4  	"context"
     5  
     6  	"github.com/spf13/pflag"
     7  	"google.golang.org/protobuf/reflect/protoreflect"
     8  )
     9  
    10  // Type specifies a custom flag type.
    11  type Type interface {
    12  	// NewValue returns a new pflag.Value which must also implement either
    13  	// SimpleValue or ListValue.
    14  	NewValue(context.Context, *Builder) Value
    15  
    16  	// DefaultValue is the default value for this type.
    17  	DefaultValue() string
    18  }
    19  
    20  // Value represents a single pflag.Value value.
    21  type Value interface {
    22  	pflag.Value
    23  	HasValue
    24  }
    25  
    26  // HasValue wraps a reference to a protobuf value.
    27  type HasValue interface {
    28  	// Get gets the value of the protobuf value reference and returns that value
    29  	// or an error. For composite protoreflect.Value types such as messages,
    30  	// lists and maps, a mutable reference to the value of field obtained with
    31  	// protoreflect.Message.NewField should be passed as the newFieldValue parameter.
    32  	Get(newFieldValue protoreflect.Value) (protoreflect.Value, error)
    33  }