Documentation ¶
Index ¶
- Constants
- Variables
- func AllNamespacesFlag(ctx context.Context, cmd *cobra.Command, c *Config, namespace *string, ...)
- func Args(cmd *cobra.Command, argDefs ...Arg)
- func CommandFromContext(ctx context.Context) *cobra.Command
- func DryRunResource(ctx context.Context, resource runtime.Object, gvk schema.GroupVersionKind)
- func ExecE(ctx context.Context, c *Config, obj Executable) func(cmd *cobra.Command, args []string) error
- func FormatArgs(cmd *cobra.Command) string
- func NamespaceFlag(ctx context.Context, cmd *cobra.Command, c *Config, namespace *string)
- func NewCacheDiscoveryClient(discoveryClient *discovery.DiscoveryClient) *cachedDiscoveryClient
- func NewConfirmSurvey(c *Config, format string, a ...any) *interact.Interaction
- func PrintPrompt(shouldPrint bool, printer func(string, ...interface{}) (int, error), ...)
- func PrintPromptWithEmoji(shouldPrint bool, printer func(Icon, string, ...interface{}) (int, error), ...)
- func ReadStdin(c *Config, value *[]byte, prompt string) func(*cobra.Command, []string) error
- func Sequence(items ...func(cmd *cobra.Command, args []string) error) func(*cobra.Command, []string) error
- func SilenceError(err error) error
- func StdoutFromContext(ctx context.Context) io.Writer
- func StripDash(flagName string) string
- func ValidateE(ctx context.Context, obj validation.Validatable) func(cmd *cobra.Command, args []string) error
- func Visit(cmd *cobra.Command, f func(c *cobra.Command) error) error
- func WithCommand(ctx context.Context, cmd *cobra.Command) context.Context
- func WithStdout(ctx context.Context, stdout io.Writer) context.Context
- type Arg
- type Client
- type Config
- func (c *Config) Boldf(format string, a ...interface{}) (n int, err error)
- func (c *Config) Eboldf(format string, a ...interface{}) (n int, err error)
- func (c *Config) Eerrorf(format string, a ...interface{}) (n int, err error)
- func (c *Config) Efaintf(format string, a ...interface{}) (n int, err error)
- func (c *Config) Einfof(format string, a ...interface{}) (n int, err error)
- func (c *Config) Emoji(emoji Icon, format string, a ...interface{}) (n int, err error)
- func (c *Config) Eprintf(format string, a ...interface{}) (n int, err error)
- func (c *Config) Errorf(format string, a ...interface{}) (n int, err error)
- func (c *Config) Esuccessf(format string, a ...interface{}) (n int, err error)
- func (c *Config) Faintf(format string, a ...interface{}) (n int, err error)
- func (c *Config) Infof(format string, a ...interface{}) (n int, err error)
- func (c *Config) Printf(format string, a ...interface{}) (n int, err error)
- func (c *Config) Successf(format string, a ...interface{}) (n int, err error)
- type DryRunable
- type Executable
- type Icon
Constants ¶
View Source
const ( NameArgumentName = "name" NamesArgumentName = "name(s)" )
View Source
const ( AllNamespacesFlagName = "--all-namespaces" ContextFlagName = "--context" KubeConfigFlagName = "--kubeconfig" NamespaceFlagName = "--namespace" NoColorFlagName = "--no-color" )
Variables ¶
View Source
var ErrIgnoreArg = fmt.Errorf("ignore argument")
View Source
var SilentError = &silentError{}
Functions ¶
func AllNamespacesFlag ¶
func DryRunResource ¶
func ExecE ¶
func ExecE(ctx context.Context, c *Config, obj Executable) func(cmd *cobra.Command, args []string) error
ExecE bridges a cobra RunE function to the Executable interface. All flags and arguments must already be bound, with explicit or default values, to the struct being executed. This function is typically used to define the RunE phase of a command.
```
cmd := &cobra.Command{ ... RunE: cli.ExecE(c, obj), }
```
func FormatArgs ¶
func NamespaceFlag ¶
func NewCacheDiscoveryClient ¶ added in v0.9.0
func NewCacheDiscoveryClient(discoveryClient *discovery.DiscoveryClient) *cachedDiscoveryClient
func NewConfirmSurvey ¶ added in v0.10.0
func NewConfirmSurvey(c *Config, format string, a ...any) *interact.Interaction
NewConfirmSurvey create a survey asking for [yN] confirmation when `Resolve` is called
func PrintPrompt ¶ added in v0.11.0
func PrintPromptWithEmoji ¶ added in v0.11.0
func SilenceError ¶
func ValidateE ¶
func ValidateE(ctx context.Context, obj validation.Validatable) func(cmd *cobra.Command, args []string) error
ValidateE bridges a cobra RunE function to the Validatable interface. All flags and arguments must already be bound, with explicit or default values, to the struct being validated. This function is typically used to define the PreRunE phase of a command.
```
cmd := &cobra.Command{ ... PreRunE: cli.ValidateE(obj), }
```
Types ¶
type Arg ¶
type Arg struct { Name string Arity int Optional bool Set func(cmd *cobra.Command, args []string, offset int) error }
func BareDoubleDashArgs ¶
func OptionalNameArg ¶
type Client ¶
type Client interface { DefaultNamespace() string KubeRestConfig() *rest.Config Discovery() discovery.DiscoveryInterface SetLogger(logger logr.Logger) ToDiscoveryClient() (discovery.CachedDiscoveryInterface, error) ToRESTConfig() (*rest.Config, error) ToRESTMapper() (meta.RESTMapper, error) crclient.Client }
type Config ¶
type Config struct { Name string Client Scheme *runtime.Scheme ViperConfigFile string KubeConfigFile string CurrentContext string TanzuIgnoreFile string Exec func(ctx context.Context, command string, args ...string) *exec.Cmd Stdin io.Reader Stdout io.Writer Stderr io.Writer Verbose *int32 Builder *resource.Builder NoColor bool }
type DryRunable ¶
type DryRunable interface {
IsDryRun() bool
}
type Icon ¶ added in v0.9.0
type Icon rune
const ( FloppyDisk Icon = '💾' Package Icon = '📦' Delivery Icon = '🚚' SpeechBalloon Icon = '💬' Magnifying Icon = '🔎' Repeat Icon = '🔁' Antenna Icon = '📡' Ship Icon = '🚢' Envelop Icon = '✉' IncomingEnvelop Icon = '📨' Canoe Icon = '🛶' Inbox Icon = '📥' Question Icon = '❓' ThumbsUp Icon = '👍' Exclamation Icon = '❗' )
Source Files ¶
Click to show internal directories.
Click to hide internal directories.