base

package
v0.0.0-...-a6f5042 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WrapRunE

func WrapRunE(o Runnable, f util.Factory) func(cmd *cobra.Command, args []string) error

WrapRunE creates a cobra RunE function that has access to the factory.

Types

type Options

type Options struct {
	// IOStreams provides the standard names for iostreams
	IOStreams util.IOStreams

	// Output defines the output format of the version information. Either 'yaml' or 'json'
	Output string
}

Options contains all settings that are used across all commands in gardenctl.

func NewOptions

func NewOptions(ioStreams util.IOStreams) *Options

NewOptions returns initialized Options.

func (*Options) AddFlags

func (o *Options) AddFlags(flags *pflag.FlagSet)

AddFlags adds flags to adjust the output to a cobra command.

func (*Options) AllowedOutputFormats

func (o *Options) AllowedOutputFormats() []string

AllowedOutputFormats returns the allowed formats for the output flag.

func (*Options) Complete

func (o *Options) Complete(_ util.Factory, _ *cobra.Command, _ []string) error

Complete adapts from the command line args to the data required.

func (*Options) PrintObject

func (o *Options) PrintObject(obj interface{}) error

PrintObject prints an object to IOStreams.out, using o.Output to print in the selected output format.

func (*Options) RegisterCompletionsForOutputFlag

func (o *Options) RegisterCompletionsForOutputFlag(cmd *cobra.Command)

RegisterCompletionsForOutputFlag adds output flag completion to the command.

func (*Options) Run

func (o *Options) Run(util.Factory) error

Run does the actual work of the command.

func (*Options) Validate

func (o *Options) Validate() error

Validate validates the provided options.

type Runnable

type Runnable interface {
	// Complete adapts from the command line args to the data required.
	Complete(util.Factory, *cobra.Command, []string) error
	// Validate validates the provided options.
	Validate() error
	// Run does the actual work of the command.
	Run(util.Factory) error
}

Runnable is the base interface for command options.

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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