Documentation ¶
Index ¶
- Constants
- Variables
- func ParseTemplate(hookTemplate string, cmd *cobra.Command) (string, error)
- func PrintNextSteps(out io.Writer, messages []string)
- func TemplateReplaceArg(i int) string
- func TemplateReplaceFlagValue(flag string) string
- func TemplateReplaceSubcommandName() string
- type HookMessage
- type HookType
Constants ¶
const (
NextSteps = iota
)
Variables ¶
var ErrHookTemplateParse = errors.New("failed to parse hook template")
Functions ¶
func PrintNextSteps ¶
func TemplateReplaceArg ¶
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 ¶
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 ¶
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.