cmdutils

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2019 License: Apache-2.0 Imports: 14 Imported by: 1

Documentation

Index

Constants

View Source
const IncompatibleFlags = "cannot be used at the same time"

Variables

View Source
var CheckNameArgError = defaultNameArgsError
View Source
var ExecErrorHandler = defaultExecErrorHandler
View Source
var PulsarCtlConfig = ClusterConfig{}

Functions

func AddVerbCmd

func AddVerbCmd(flagGrouping *FlagGrouping, parentResourceCmd *cobra.Command, newVerbCmd func(*VerbCmd))

AddVerbCmd create a registers a new command under the given resource command

func AddVerbCmds

func AddVerbCmds(flagGrouping *FlagGrouping, parentResourceCmd *cobra.Command, newVerbCmd ...func(cmd *VerbCmd))

func GetNameArg

func GetNameArg(args []string, errMsg string) (string, error)

GetNameArg tests to ensure there is only 1 name argument

func GetNameArgs

func GetNameArgs(args []string, check func(args []string) error) ([]string, error)

func NewPulsarClient

func NewPulsarClient() pulsar.Client

func NewPulsarClientWithAPIVersion

func NewPulsarClientWithAPIVersion(version pulsar.APIVersion) pulsar.Client

func NewResourceCmd

func NewResourceCmd(use, short, long string, aliases ...string) *cobra.Command

NewVerbCmd defines a standard resource command

func PrintError

func PrintError(w io.Writer, err error)

func PrintJSON

func PrintJSON(w io.Writer, obj interface{})

func RunFuncWithTimeout

func RunFuncWithTimeout(task func([]string, interface{}) bool, condition bool, timeout time.Duration,
	args []string, obj interface{}) error

Types

type ClusterConfig

type ClusterConfig struct {
	// the web service url that pulsarctl connects to. Default is http://localhost:8080
	WebServiceURL string
	// Set the path to the trusted TLS certificate file
	TLSTrustCertsFilePath string
	// Configure whether the Pulsar client accept untrusted TLS certificate from broker (default: false)
	TLSAllowInsecureConnection bool

	AuthParams string

	// Token and TokenFile is used to config the pulsarctl using token to authentication
	Token     string
	TokenFile string
}

the configuration of the cluster that pulsarctl connects to

func (*ClusterConfig) Client

func (c *ClusterConfig) Client(version pulsar.APIVersion) pulsar.Client

func (*ClusterConfig) FlagSet

func (c *ClusterConfig) FlagSet() *pflag.FlagSet

type FlagGrouping

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

FlagGrouping holds a superset of all flagsets for all commands

func NewGrouping

func NewGrouping() *FlagGrouping

NewGrouping creates an instance of Grouping

func (*FlagGrouping) New

New creates a new group of flagsets for use with a subcommand

func (*FlagGrouping) Usage

func (g *FlagGrouping) Usage(cmd *cobra.Command) error

Usage is for use with (*cobra.Command).SetUsageFunc

type NamedFlagSetGroup

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

NamedFlagSetGroup holds a single group of flagsets

func (*NamedFlagSetGroup) AddTo

func (n *NamedFlagSetGroup) AddTo(cmd *cobra.Command)

AddTo mixes all flagsets in the given group to another flagset

func (*NamedFlagSetGroup) InFlagSet

func (n *NamedFlagSetGroup) InFlagSet(name string, cb func(*pflag.FlagSet))

InFlagSet returns new or existing named FlagSet in a group

type VerbCmd

type VerbCmd struct {
	Command      *cobra.Command
	FlagSetGroup *NamedFlagSetGroup
	NameArg      string
	NameArgs     []string

	// for testing
	NameError error
}

VerbCmd holds attributes that most of the commands use

func (*VerbCmd) SetDescription

func (vc *VerbCmd) SetDescription(use, short, long, example string, aliases ...string)

SetDescription sets usage along with short and long descriptions as well as aliases

func (*VerbCmd) SetRunFunc

func (vc *VerbCmd) SetRunFunc(cmd func() error)

SetRunFunc registers a command function

func (*VerbCmd) SetRunFuncWithMultiNameArgs

func (vc *VerbCmd) SetRunFuncWithMultiNameArgs(cmd func() error, checkArgs func(args []string) error)

func (*VerbCmd) SetRunFuncWithNameArg

func (vc *VerbCmd) SetRunFuncWithNameArg(cmd func() error, errMsg string)

SetRunFuncWithNameArg registers a command function with an optional name argument

Jump to

Keyboard shortcuts

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