flags

package
v0.0.0-...-766ab8f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 8, 2024 License: Apache-2.0 Imports: 15 Imported by: 1

Documentation

Index

Constants

View Source
const (
	DefaultPort = 3000
	DefaultIPv4 = "127.0.0.1"
)
View Source
const (
	DefaultMaxLineLength = 65
)

Variables

View Source
var (
	ErrEnvironmentVariableNotFound = fmt.Errorf("environment variable not found")
)

Functions

func DefaultWrapHelpString

func DefaultWrapHelpString(val string) string

func SetupRoot

func SetupRoot(rootCmd *cobra.Command, appLongName, version string)

SetupRoot sets up the root command with common flags and options. It takes the rootCmd and appLongName as parameters. It registers the "help" alias for the "usage" flag. It adds the "version" as uppercase "V" flag to the rootCmd. It sets the version template for the rootCmd using appLongName. If appLongName is "Unique Data Agent", the version template will be:

Unique Data Agent Version 1.2.3

func WrapString

func WrapString(val string, lineLen int) string

Types

type AerospikeFlags

type AerospikeFlags struct {
	Seeds          HostTLSPortSliceFlag `mapstructure:"host"`
	DefaultPort    int                  `mapstructure:"port"`
	User           string               `mapstructure:"user"`
	Password       PasswordFlag         `mapstructure:"password"`
	AuthMode       AuthModeFlag         `mapstructure:"auth"`
	TLSEnable      bool                 `mapstructure:"tls-enable"`
	TLSName        string               `mapstructure:"tls-name"`
	TLSProtocols   TLSProtocolsFlag     `mapstructure:"tls-protocols"`
	TLSRootCAFile  CertFlag             `mapstructure:"tls-cafile"`
	TLSRootCAPath  CertPathFlag         `mapstructure:"tls-capath"`
	TLSCertFile    CertFlag             `mapstructure:"tls-certfile"`
	TLSKeyFile     CertFlag             `mapstructure:"tls-keyfile"`
	TLSKeyFilePass PasswordFlag         `mapstructure:"tls-keyfile-password"`
}

AerospikeFlags defines the storage backing for Aerospike pflags.FlagSet returned from SetAerospikeFlags.

func NewDefaultAerospikeFlags

func NewDefaultAerospikeFlags() *AerospikeFlags

func (*AerospikeFlags) NewAerospikeConfig

func (af *AerospikeFlags) NewAerospikeConfig() *client.AerospikeConfig

func (*AerospikeFlags) NewFlagSet

func (af *AerospikeFlags) NewFlagSet(fmtUsage UsageFormatter) *pflag.FlagSet

NewAerospikeFlagSet returns a new pflag.FlagSet with Aerospike flags defined. Values set in the returned FlagSet will be stored in the AerospikeFlags argument.

type AuthModeFlag

type AuthModeFlag as.AuthMode

AuthModeFlag defines a Cobra compatible flag for the --auth flag.

func (*AuthModeFlag) Set

func (mode *AuthModeFlag) Set(val string) error

func (*AuthModeFlag) String

func (mode *AuthModeFlag) String() string

func (*AuthModeFlag) Type

func (mode *AuthModeFlag) Type() string

type CertFlag

type CertFlag []byte

CertFlag defines a Cobra compatible flag for retrieving cryptographic certificates. This supports various Aerospike certificate configurations. examples include... --tls-cafile --tls-certfile --tls-keyfile

func (*CertFlag) Set

func (flag *CertFlag) Set(val string) error

func (*CertFlag) String

func (flag *CertFlag) String() string

func (*CertFlag) Type

func (flag *CertFlag) Type() string

type CertPathFlag

type CertPathFlag [][]byte

CertFlag defines a Cobra compatible flag for flags that resolve to a list of certificates. examples include... --tls-capath

func (*CertPathFlag) Set

func (slice *CertPathFlag) Set(val string) error

func (*CertPathFlag) String

func (slice *CertPathFlag) String() string

func (*CertPathFlag) Type

func (slice *CertPathFlag) Type() string

type ConfFileFlags

type ConfFileFlags struct {
	File     string // Config file path.
	Instance string // Instance name appended to top-level context e.g. instance=tls will read from cluster_tls.
}

ConfFileFlags represents the flags related to setting up the config file.

func NewConfFileFlags

func NewConfFileFlags() *ConfFileFlags

func (*ConfFileFlags) NewFlagSet

func (cf *ConfFileFlags) NewFlagSet(fmtUsage UsageFormatter) *pflag.FlagSet

NewFlagSet creates a new pflag.FlagSet with the config file flags. The fmtUsage parameter is a function that formats the usage string.

type HostTLSPortSliceFlag

type HostTLSPortSliceFlag struct {
	Seeds client.HostTLSPortSlice
	// contains filtered or unexported fields
}

A cobra PFlag to parse and display help info for the host[:tls-name][:port] input option. It implements the pflag Value and SliceValue interfaces to enable automatic parsing by cobra.

func NewHostTLSPortSliceFlag

func NewHostTLSPortSliceFlag() HostTLSPortSliceFlag

func (*HostTLSPortSliceFlag) Append

func (slice *HostTLSPortSliceFlag) Append(val string) error

Append adds the specified value to the end of the flag value list.

func (*HostTLSPortSliceFlag) GetSlice

func (slice *HostTLSPortSliceFlag) GetSlice() []string

GetSlice returns the flag value list as an array of strings.

func (*HostTLSPortSliceFlag) Replace

func (slice *HostTLSPortSliceFlag) Replace(vals []string) error

Replace will fully overwrite any data currently in the flag value list.

func (*HostTLSPortSliceFlag) Set

func (slice *HostTLSPortSliceFlag) Set(commaSepVal string) error

func (*HostTLSPortSliceFlag) String

func (slice *HostTLSPortSliceFlag) String() string

func (*HostTLSPortSliceFlag) Type

func (slice *HostTLSPortSliceFlag) Type() string

type PasswordFlag

type PasswordFlag []byte

PasswordFlag defines a Cobra compatible flag for password related options. examples include --password --tls-keyfile-password

func (*PasswordFlag) Set

func (flag *PasswordFlag) Set(val string) error

func (*PasswordFlag) String

func (flag *PasswordFlag) String() string

func (*PasswordFlag) Type

func (flag *PasswordFlag) Type() string

type TLSProtocolsFlag

type TLSProtocolsFlag struct {
	// contains filtered or unexported fields
}

TLSProtocolsFlag defines a Cobra compatible flag for dealing with tls protocols. Example flags include. --tls--protocols

func NewDefaultTLSProtocolsFlag

func NewDefaultTLSProtocolsFlag() TLSProtocolsFlag

func (*TLSProtocolsFlag) Set

func (flag *TLSProtocolsFlag) Set(val string) error

func (*TLSProtocolsFlag) String

func (flag *TLSProtocolsFlag) String() string

func (*TLSProtocolsFlag) Type

func (flag *TLSProtocolsFlag) Type() string

type UsageFormatter

type UsageFormatter func(string) string

UsageFormatter provides a method for modifying the usage text of the flags returned by SetAerospikeFlags.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL