cli

package
v4.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2024 License: Apache-2.0 Imports: 23 Imported by: 2

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

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) Command added in v4.1.1

func (c CLI) Command() *cobra.Command

Command returns the underlying root command.

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 WithFilesystem added in v4.1.1

func WithFilesystem(fs machinery.Filesystem) Option

WithFilesystem is an Option that allows to set the filesystem used in the CLI.

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

Jump to

Keyboard shortcuts

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