Documentation ¶
Index ¶
- func AddCommonQueryFlag(flags *pflag.FlagSet, parameters *query.Parameters)
- func AddFormatFlag(flags *pflag.FlagSet)
- func AddFormatFlagDefault(flags *pflag.FlagSet, defValue string)
- func AddQueryingFlags(flags *pflag.FlagSet, parameters *query.Parameters)
- func BuildRootCommand(ctx *Context) *cobra.Command
- func CommonConfirmationPrompt(message string, ctx *Context, input io.Reader) (bool, error)
- func CommonPrepare(cmd Command, ctx *Context) func(*cobra.Command, []string) error
- func CommonPrintDeclineMessage(wr io.Writer)
- func Execute(cmd *cobra.Command)
- func RunE(cmd Command) func(*cobra.Command, []string) error
- func SmPrepare(cmd Command, ctx *Context) func(*cobra.Command, []string) error
- type Command
- type CommandPreparator
- type ConfirmedCommand
- type Context
- type FormattedCommand
- type Group
- type HiddenUsageCommand
- type PrepareFunc
- type ValidatedCommand
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddCommonQueryFlag ¶ added in v1.6.0
func AddCommonQueryFlag(flags *pflag.FlagSet, parameters *query.Parameters)
AddCommonQueryFlag adds the CLI param that provides general query parameters
func AddFormatFlag ¶
AddFormatFlag adds the --output (-o) flag.
func AddFormatFlagDefault ¶ added in v1.5.0
AddFormatFlagDefault is same as AddFormatFlag but allows to set default value.
func AddQueryingFlags ¶ added in v1.5.0
func AddQueryingFlags(flags *pflag.FlagSet, parameters *query.Parameters)
AddQueryingFlags adds --field-query (-f) and --label-query (-l) flags
func BuildRootCommand ¶
BuildRootCommand builds a new SM root command with context
func CommonConfirmationPrompt ¶ added in v1.5.0
CommonConfirmationPrompt provides common logic for confirmation of an operation
func CommonPrepare ¶
CommonPrepare provides common pre-run logic for SM commands
func CommonPrintDeclineMessage ¶ added in v1.5.0
CommonPrintDeclineMessage provides common confirmation declined message
Types ¶
type CommandPreparator ¶
type CommandPreparator interface {
Prepare(PrepareFunc) *cobra.Command
}
CommandPreparator used to wrap CLI commands
type ConfirmedCommand ¶ added in v1.5.0
type ConfirmedCommand interface { // AskForConfirmation asks user to confirm the execution of desired operation AskForConfirmation() (bool, error) // PrintDeclineMessage prints message to the user if the confirmation is declined PrintDeclineMessage() }
ConfirmedCommand should be implemented if the command should ask for user confirmation prior execution
type Context ¶
type Context struct { // Output should be used when printing in commands, instead of directly writing to stdout/stderr, to enable unit testing. Output io.Writer Client smclient.Client Verbose bool Configuration configuration.Configuration Parameters query.Parameters }
Context is used as a context for the commands
type FormattedCommand ¶
type FormattedCommand interface { // SetOutputFormat sets the command's output format SetOutputFormat(output.Format) }
FormattedCommand should be implemented if the command supports different output formatting through a --format or -f flag
type Group ¶
type Group struct { PrepareFn PrepareFunc Commands []CommandPreparator }
Group contains commands which have common prepare function
type HiddenUsageCommand ¶
type HiddenUsageCommand interface { // HideUsage returns true when usage should be hidden and false otherwise HideUsage() bool }
HiddenUsageCommand should be implemented if the command should not print its usage
type PrepareFunc ¶
PrepareFunc is function type which executes common prepare logic for commands
type ValidatedCommand ¶
type ValidatedCommand interface { // Validate command usage in the implementation of this method Validate([]string) error }
ValidatedCommand should be implemented if the command will have validation