cli

package
v3.6.0 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2022 License: Apache-2.0 Imports: 24 Imported by: 10

Documentation

Overview

Package cli provides the required tools to build a CLI utility that creates scaffolds for operator projects.

It is the entrypoint for any CLI that wants to use kubebuilder's scaffolding capabilities.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DiscoverExternalPlugins added in v3.5.0

func DiscoverExternalPlugins(fs afero.Fs) (ps []plugin.Plugin, err error)

DiscoverExternalPlugins discovers the external plugins in the plugins root directory and adds them to external.Plugin.

Types

type CLI

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

CLI is the command line utility that is used to scaffold kubebuilder project files.

func New

func New(options ...Option) (*CLI, error)

New creates a new CLI instance.

It follows the functional options pattern in order to customize the resulting CLI.

It returns an error if any of the provided options fails. As some processing needs to be done, execution errors may be found here. Instead of returning an error, this function will return a valid CLI that errors in Run so that help is provided to the user.

func (CLI) Run

func (c CLI) Run() error

Run executes the CLI utility.

If an error is found, command help and examples will be printed.

type Option

type Option func(*CLI) error

Option is a function used as arguments to New in order to configure the resulting CLI.

func WithCommandName

func WithCommandName(name string) Option

WithCommandName is an Option that sets the CLI's root command name.

func WithCompletion

func WithCompletion() Option

WithCompletion is an Option that adds the completion subcommand.

func WithDefaultPlugins

func WithDefaultPlugins(projectVersion config.Version, plugins ...plugin.Plugin) Option

WithDefaultPlugins is an Option that sets the CLI's default plugins.

Specifying any invalid plugin results in an error.

func WithDefaultProjectVersion

func WithDefaultProjectVersion(version config.Version) Option

WithDefaultProjectVersion is an Option that sets the CLI's default project version.

Setting an invalid version results in an error.

func WithDescription

func WithDescription(description string) Option

WithDescription is an Option that sets the CLI's root description.

func WithExtraAlphaCommands

func WithExtraAlphaCommands(cmds ...*cobra.Command) Option

WithExtraAlphaCommands is an Option that adds extra alpha subcommands to the CLI.

Adding extra alpha commands that duplicate existing commands results in an error.

func WithExtraCommands

func WithExtraCommands(cmds ...*cobra.Command) Option

WithExtraCommands is an Option that adds extra subcommands to the CLI.

Adding extra commands that duplicate existing commands results in an error.

func WithPlugins

func WithPlugins(plugins ...plugin.Plugin) Option

WithPlugins is an Option that sets the CLI's plugins.

Specifying any invalid plugin results in an error.

func WithVersion

func WithVersion(version string) Option

WithVersion is an Option that defines the version string of the CLI.

Directories

Path Synopsis
alpha

Jump to

Keyboard shortcuts

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