command

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2024 License: BSD-2-Clause Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HealthyPlugin

type HealthyPlugin struct{}

HealthyPlugin is the struct implementing the interface defined by the core CLI. It can be found at "code.cloudfoundry.org/cli/plugin/plugin.go"

func (*HealthyPlugin) GetMetadata

func (c *HealthyPlugin) GetMetadata() plugin.PluginMetadata

GetMetadata must be implemented as part of the plugin interface defined by the core CLI.

GetMetadata() returns a PluginMetadata struct. The first field, Name, determines the name of the plugin which should generally be without spaces. If there are spaces in the name a user will need to properly quote the name during uninstall otherwise the name will be treated as separate arguments. The second value is a slice of Command structs. Our slice only contains one Command Struct, but could contain any number of them. The first field Name defines the command `cf basic-plugin-command` once installed into the CLI. The second field, HelpText, is used by the core CLI to display help information to the user in the core commands `cf help`, `cf`, or `cf -h`.

func (*HealthyPlugin) Run

func (c *HealthyPlugin) Run(cliConnection plugin.CliConnection, args []string)

Run must be implemented by any plugin because it is part of the plugin interface defined by the core CLI.

Run(....) is the entry point when the core CLI is invoking a command defined by a plugin. The first parameter, plugin.CliConnection, is a struct that can be used to invoke cli commands. The second parameter, args, is a slice of strings. args[0] will be the name of the command, and will be followed by any additional arguments a cli user typed in.

Any error handling should be handled with the plugin itself (this means printing user facing errors). The CLI will exit 0 if the plugin exits 0 and will exit 1 should the plugin exits nonzero.

type Logger

type Logger interface {
	Fatalf(format string, args ...interface{})
	Printf(format string, args ...interface{})
}

Logger is used for outputting log-cache results and errors

Jump to

Keyboard shortcuts

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