plugin

package
v0.0.0-...-b25b198 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2023 License: Apache-2.0 Imports: 15 Imported by: 9

Documentation

Overview

Package plugin provides functions to create new CLI plugins.

Index

Constants

View Source
const CmdTemplate = `` /* 1078-byte string literal not displayed */

CmdTemplate is the template for plugin commands.

View Source
const DefaultDocsDir = "docs/cli/commands"

DefaultDocsDir is the base docs directory

View Source
const ErrorDocsOutputFolderNotExists = "" /* 137-byte string literal not displayed */

Variables

View Source
var TemplateFuncs = template.FuncMap{
	"rpad":                    component.Rpad,
	"bold":                    component.Bold,
	"underline":               component.Underline,
	"trimTrailingWhitespaces": component.TrimRightSpace,
	"beginsWith":              component.BeginsWith,
}

TemplateFuncs are the template usage funcs.

View Source
var UsageFunc = func(c *cobra.Command) error {
	t, err := template.New("usage").Funcs(TemplateFuncs).Parse(CmdTemplate)
	if err != nil {
		return err
	}
	return t.Execute(os.Stdout, c)
}

UsageFunc is the usage func for a plugin.

Functions

func ApplyDefaultConfig

func ApplyDefaultConfig(p *cliapi.PluginDescriptor)

ApplyDefaultConfig applies default configurations to plugin descriptor.

func ValidatePlugin

func ValidatePlugin(p *cliapi.PluginDescriptor) (err error)

ValidatePlugin validates the plugin descriptor.

Types

type Plugin

type Plugin struct {
	Cmd *cobra.Command
}

Plugin is a Tanzu CLI plugin.

func NewPlugin

func NewPlugin(descriptor *cliapi.PluginDescriptor) (*Plugin, error)

NewPlugin creates an instance of Plugin.

func NewPluginFromFile

func NewPluginFromFile(path string) (*Plugin, error)

NewPluginFromFile create a new instance of Plugin from a file descriptor.

func (*Plugin) AddCommands

func (p *Plugin) AddCommands(commands ...*cobra.Command)

AddCommands adds commands to the plugin.

func (*Plugin) Execute

func (p *Plugin) Execute() error

Execute executes the plugin.

Directories

Path Synopsis
Package lint provides linters to run against CLI plugins.
Package lint provides linters to run against CLI plugins.

Jump to

Keyboard shortcuts

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