Documentation ¶
Index ¶
- Constants
- Variables
- func AddVerbCmd(flagGrouping *FlagGrouping, parentResourceCmd *cobra.Command, ...)
- func AddVerbCmds(flagGrouping *FlagGrouping, parentResourceCmd *cobra.Command, ...)
- func Exists(path string) bool
- func GetNameArg(args []string, errMsg string) (string, error)
- func GetNameArgs(args []string, check func(args []string) error) ([]string, error)
- func NewBookieClient() bookkeeper.Client
- func NewPulsarClient() pulsar.Client
- func NewPulsarClientWithAPIVersion(version common.APIVersion) pulsar.Client
- func NewResourceCmd(use, short, long string, aliases ...string) *cobra.Command
- func PrintError(w io.Writer, err error)
- func PrintJSON(w io.Writer, obj interface{})
- func RunFuncWithTimeout(task func([]string, interface{}) bool, condition bool, timeout time.Duration, ...) error
- type AuthInfo
- type ClusterConfig
- type Config
- type ConfigOverrides
- type Context
- type Example
- type FlagGrouping
- type LongDescription
- type NamedFlagSetGroup
- type Output
- type OutputConfig
- type OutputContent
- func (o OutputContent) Negotiate(format OutputFormat) OutputWritable
- func (o *OutputContent) WithObject(obj interface{}) *OutputContent
- func (o *OutputContent) WithObjectFunc(f func() interface{}) *OutputContent
- func (o *OutputContent) WithText(format string, i ...interface{}) *OutputContent
- func (o *OutputContent) WithTextFunc(f func(w io.Writer) error) *OutputContent
- type OutputFormat
- type OutputNegotiable
- type OutputNegotiableFunc
- type OutputWritable
- type OutputWritableFunc
- type VerbCmd
- func (vc *VerbCmd) EnableOutputFlagSet()
- func (vc *VerbCmd) SetDescription(use, short, long, example string, aliases ...string)
- func (vc *VerbCmd) SetRunFunc(cmd func() error)
- func (vc *VerbCmd) SetRunFuncWithMultiNameArgs(cmd func() error, checkArgs func(args []string) error)
- func (vc *VerbCmd) SetRunFuncWithNameArg(cmd func() error, errMsg string)
Constants ¶
const IncompatibleFlags = "cannot be used at the same time"
Variables ¶
var CheckNameArgError = defaultNameArgsError
var EXAMPLES = "EXAMPLES:"
var ExecErrorHandler = defaultExecErrorHandler
var OUTPUT = "OUTPUT:"
var PERMISSION = "REQUIRED PERMISSION:"
var PulsarCtlConfig = loadFromEnv()
var SCOPE = "SCOPE:"
var SPACES = " "
var USEDFOR = "USED FOR:"
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 ¶
GetNameArg tests to ensure there is only 1 name argument
func GetNameArgs ¶
func NewBookieClient ¶ added in v0.2.0
func NewBookieClient() bookkeeper.Client
func NewPulsarClient ¶
func NewPulsarClientWithAPIVersion ¶
func NewPulsarClientWithAPIVersion(version common.APIVersion) pulsar.Client
func NewResourceCmd ¶
NewVerbCmd defines a standard resource command
func PrintError ¶
Types ¶
type AuthInfo ¶ added in v0.3.0
type AuthInfo struct { LocationOfOrigin string TLSTrustCertsFilePath string `yaml:"tls_trust_certs_file_path"` TLSAllowInsecureConnection bool `yaml:"tls_allow_insecure_connection"` Token string `yaml:"token"` TokenFile string `yaml:"tokenFile"` // OAuth2 configuration IssuerEndpoint string `yaml:"issuer_endpoint"` ClientID string `yaml:"client_id"` Audience string `yaml:"audience"` KeyFile string `yaml:"key_file"` }
type ClusterConfig ¶
the configuration of the cluster that pulsarctl connects to
func (*ClusterConfig) BookieClient ¶ added in v0.2.0
func (c *ClusterConfig) BookieClient() bookkeeper.Client
func (*ClusterConfig) Client ¶
func (c *ClusterConfig) Client(version common.APIVersion) pulsar.Client
func (*ClusterConfig) DecodeContext ¶ added in v0.3.0
func (c *ClusterConfig) DecodeContext() *Config
func (*ClusterConfig) FlagSet ¶
func (c *ClusterConfig) FlagSet() *pflag.FlagSet
type Config ¶ added in v0.3.0
type ConfigOverrides ¶ added in v0.3.0
type FlagGrouping ¶
type FlagGrouping struct {
// contains filtered or unexported fields
}
FlagGrouping holds a superset of all flagsets for all commands
func (*FlagGrouping) New ¶
func (g *FlagGrouping) New(cmd *cobra.Command) *NamedFlagSetGroup
New creates a new group of flagsets for use with a subcommand
type LongDescription ¶ added in v0.2.0
type LongDescription struct { CommandUsedFor string CommandPermission string CommandExamples []Example CommandOutput []Output CommandScope string }
func (*LongDescription) ExampleToString ¶ added in v0.2.0
func (desc *LongDescription) ExampleToString() string
func (*LongDescription) ToString ¶ added in v0.2.0
func (desc *LongDescription) ToString() string
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
type OutputConfig ¶ added in v0.3.0
type OutputConfig struct { // the output format (Table, Plain, Json, Yaml) Format string }
OutputConfig represents an output configuration
func (*OutputConfig) AddTo ¶ added in v0.3.0
func (c *OutputConfig) AddTo(group *NamedFlagSetGroup)
AddTo registers the output flagset into a group
func (*OutputConfig) WriteOutput ¶ added in v0.3.0
func (c *OutputConfig) WriteOutput(w io.Writer, f OutputNegotiable) error
WriteOutput writes output based on the configured output format and on available content
type OutputContent ¶ added in v0.3.0
type OutputContent struct {
// contains filtered or unexported fields
}
OutputContent adapts various Go types to output format(s)
func NewOutputContent ¶ added in v0.3.0
func NewOutputContent() *OutputContent
func (OutputContent) Negotiate ¶ added in v0.3.0
func (o OutputContent) Negotiate(format OutputFormat) OutputWritable
Negotiate produces an OutputWritable based on available content
func (*OutputContent) WithObject ¶ added in v0.3.0
func (o *OutputContent) WithObject(obj interface{}) *OutputContent
func (*OutputContent) WithObjectFunc ¶ added in v0.3.0
func (o *OutputContent) WithObjectFunc(f func() interface{}) *OutputContent
func (*OutputContent) WithText ¶ added in v0.3.0
func (o *OutputContent) WithText(format string, i ...interface{}) *OutputContent
WithText produces the given formatted string
func (*OutputContent) WithTextFunc ¶ added in v0.3.0
func (o *OutputContent) WithTextFunc(f func(w io.Writer) error) *OutputContent
type OutputFormat ¶ added in v0.3.0
type OutputFormat string
OutputFormat represents a user-configured output format
const ( TextOutputFormat OutputFormat = "text" JSONOutputFormat OutputFormat = "json" YAMLOutputFormat OutputFormat = "yaml" )
func (OutputFormat) String ¶ added in v0.3.0
func (fmt OutputFormat) String() string
type OutputNegotiable ¶ added in v0.3.0
type OutputNegotiable interface { // Negotiate produces an OutputWritable for the given output format, or nil if the format isn't supported Negotiate(format OutputFormat) OutputWritable }
OutputNegotiable facilitates content negotiation
type OutputNegotiableFunc ¶ added in v0.3.0
type OutputNegotiableFunc func(format OutputFormat) OutputWritable
func (OutputNegotiableFunc) Negotiate ¶ added in v0.3.0
func (f OutputNegotiableFunc) Negotiate(format OutputFormat) OutputWritable
type OutputWritable ¶ added in v0.3.0
OutputWritable indicates an object that is writable to a given io.Writer
type OutputWritableFunc ¶ added in v0.3.0
OutputWritableFunc adapts a function as an OutputWritable
type VerbCmd ¶
type VerbCmd struct { Command *cobra.Command FlagSetGroup *NamedFlagSetGroup NameArg string NameArgs []string NameError error // for testing OutputConfig *OutputConfig }
VerbCmd holds attributes that most of the commands use
func (*VerbCmd) EnableOutputFlagSet ¶ added in v0.3.0
func (vc *VerbCmd) EnableOutputFlagSet()
EnableOutputFlagSet adds the output flagset to the command
func (*VerbCmd) SetDescription ¶
SetDescription sets usage along with short and long descriptions as well as aliases
func (*VerbCmd) SetRunFunc ¶
SetRunFunc registers a command function
func (*VerbCmd) SetRunFuncWithMultiNameArgs ¶
func (*VerbCmd) SetRunFuncWithNameArg ¶
SetRunFuncWithNameArg registers a command function with an optional name argument