flags

package
v1.0.0-beta.4 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2018 License: Apache-2.0 Imports: 5 Imported by: 2

Documentation

Index

Constants

View Source
const (
	ApiVersionLongName    = "version"
	ApiVersionShortName   = "v"
	ApiVersionDefault     = "2.13"
	ApiVersionDescription = "[Optional] The version number of OSB API the request will use."
	BrokerLongName        = "broker"
	BrokerShortName       = "b"
	HostLongName          = "host"
	HostBrokerDefault     = "https://servicebroker.googleapis.com"
	ProjectLongName       = "project"
	ProjectShortName      = "p"
	ServerLongName        = "server"
	ServerShortName       = "s"
)

Variables

This section is empty.

Functions

func BoolFlag

func BoolFlag(flagset *pflag.FlagSet, p *bool, long, short, usage string)

BoolFlag is a wrapper to *FlagSet.BoolVarP which also does some book keeping so that the flag can be used with GetShortName and GetLongName.

func CheckFlags

func CheckFlags(requiredFlags ...interface{})

CheckFlags checks whether all given flags were specified. If any are missing this will print an error message and call os.Exit(2). requiredFlags should be pointers to the flag variables (e.g. &credsFlag).

func ConstructBrokerURL

func ConstructBrokerURL(host, project, broker string) string

func PrintMissingFlags

func PrintMissingFlags(missingFlags []Names)

Prints error message to user about missing flags.

func StringArrayFlag

func StringArrayFlag(flagset *pflag.FlagSet, p *[]string, long, short, usage string)

StringArrayFlag is a wrapper to *FlagSet.StringArrayVarP but does some additional stuff so that you can use CheckRequiredFlags with the given pointer p.

func StringFlag

func StringFlag(flagset *pflag.FlagSet, p *string, long, short, usage string)

StringFlag is a wrapper to *FlagSet.StringVarP which also does some book keeping so that the flag can be used with GetShortName and GetLongName.

func StringFlagWithDefault

func StringFlagWithDefault(flagset *pflag.FlagSet, p *string, long, short, defaultValue, usage string)

StringFlagWithDefault is a wrapper to *FlagSet.StringVarP which accepts the default value for the flag. It also does some book keeping so that the flag can be used with GetShortName and GetLongName.

Types

type BrokerURLConstructor

type BrokerURLConstructor struct {
	Broker  string
	Host    string
	Project string
	Server  string
}

BrokerURLConstructor is a struct that describes the fields which can be used to generate a broker URL via BrokerURL().

func (*BrokerURLConstructor) BrokerURL

func (flags *BrokerURLConstructor) BrokerURL() (string, error)

There are two available options for service broker commands. Users are allowed to pass either --server or (--project and --broker). If the latter is used then we generate the URL assuming we are using a GCP broker. BrokerURL checks that only one of the two options is passed in, that is, only either (--server) or (--project and --broker) are used, and returns the generated broker URL.

type Names

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

Names keeps the long and short flag names.

func CheckRequiredFlags

func CheckRequiredFlags(requiredFlags ...interface{}) []Names

CheckRequiredFlags will check that all required flags are there. You must use this package's *VarP functions instead of the *FlagSet methods for all the flags that you are passed into this function. Note that requiredFlags are not actually flags but rather pointers to the variables which are set by the user flags.

func (Names) String

func (names Names) String() string

String returns string representation of Name for pretty printing. Looks like (-, --longFlag).

Jump to

Keyboard shortcuts

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