cli

package
v3.0.0-beta.0 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2021 License: Apache-2.0 Imports: 13 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithCompletion

func WithCompletion(c *cli) error

WithCompletion is an Option that adds the completion subcommand.

Types

type CLI

type CLI interface {
	// Run runs the CLI, usually returning an error if command line configuration
	// is incorrect.
	Run() error
}

CLI interacts with a command line interface.

func New

func New(opts ...Option) (CLI, error)

New creates a new cli instance. Developer errors (e.g. not registering any plugins, extra commands with conflicting names) return an error while user errors (e.g. errors while parsing flags, unresolvable plugins) create a command which return the error.

type Option

type Option func(*cli) error

Option is a function that can configure the cli

func WithCommandName

func WithCommandName(name string) Option

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

func WithDefaultPlugins

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

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

func WithDefaultProjectVersion

func WithDefaultProjectVersion(version config.Version) Option

WithDefaultProjectVersion is an Option that sets the cli's default project version. Setting an unknown version will result 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.

func WithVersion

func WithVersion(version string) Option

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

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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