hooks

package
v0.0.0-...-01bcad7 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NextSteps = iota
)

Variables

View Source
var ErrHookTemplateParse = errors.New("failed to parse hook template")

Functions

func ParseTemplate

func ParseTemplate(hookTemplate string, cmd *cobra.Command) (string, error)

func PrintNextSteps

func PrintNextSteps(out io.Writer, messages []string)

func TemplateReplaceArg

func TemplateReplaceArg(i int) string

TemplateReplaceArg takes an index i and returns a hook template string that the CLI will replace the template with the ith argument, after processing the passed flags.

Example:

"run this image with `docker run " + TemplateReplaceArg(0) + "`"

when being executed after the command: `docker pull alpine` will result in the message: "Run this image with `docker run alpine`"

func TemplateReplaceFlagValue

func TemplateReplaceFlagValue(flag string) string

TemplateReplaceFlagValue returns a hook template string that will be replaced by the flags value.

Example:

"you ran a container named: " + TemplateReplaceFlagValue("name")

when being executed after the command: `docker run --name "my-container" alpine` will result in the message: `you ran a container named: my-container`

func TemplateReplaceSubcommandName

func TemplateReplaceSubcommandName() string

TemplateReplaceSubcommandName returns a hook template string that will be replaced by the CLI subcommand being executed

Example:

"you ran the subcommand: " + TemplateReplaceSubcommandName()

when being executed after the command: `docker run --name "my-container" alpine` will result in the message: `you ran the subcommand: run`

Types

type HookMessage

type HookMessage struct {
	Type     HookType
	Template string
}

HookMessage represents a plugin hook response. Plugins declaring support for CLI hooks need to print a json representation of this type when their hook subcommand is invoked.

type HookType

type HookType int

Jump to

Keyboard shortcuts

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