hooks

package
v29.2.0-rc.2+incompatible Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2026 License: Apache-2.0 Imports: 9 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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