Skip to content

Commit dbd65f9

Browse files
committed
Display additional help message pointing to docs.docker.com guides.
Will display when user types `docker help` or `docker --help`, but not for `docker run --help`. Signed-off-by: Guillaume Tardif <[email protected]>
1 parent 5836f20 commit dbd65f9

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

cli/cobra.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ func setupCommonRootCommand(rootCmd *cobra.Command) (*cliflags.ClientOptions, *p
3636
cobra.AddTemplateFunc("invalidPluginReason", invalidPluginReason)
3737
cobra.AddTemplateFunc("isPlugin", isPlugin)
3838
cobra.AddTemplateFunc("isExperimental", isExperimental)
39+
cobra.AddTemplateFunc("displayHelpLink", displayHelpLink)
3940
cobra.AddTemplateFunc("decoratedName", decoratedName)
4041

4142
rootCmd.SetUsageTemplate(usageTemplate)
@@ -185,7 +186,6 @@ var helpCommand = &cobra.Command{
185186
if cmd == nil || e != nil || len(args) > 0 {
186187
return errors.Errorf("unknown help topic: %v", strings.Join(args, " "))
187188
}
188-
189189
helpFunc := cmd.HelpFunc()
190190
helpFunc(cmd, args)
191191
return nil
@@ -205,6 +205,10 @@ func isExperimental(cmd *cobra.Command) bool {
205205
return experimental
206206
}
207207

208+
func displayHelpLink(cmd *cobra.Command) bool {
209+
return !cmd.HasParent()
210+
}
211+
208212
func isPlugin(cmd *cobra.Command) bool {
209213
return cmd.Annotations[pluginmanager.CommandAnnotationPlugin] == "true"
210214
}
@@ -360,6 +364,9 @@ Invalid Plugins:
360364
361365
Run '{{.CommandPath}} COMMAND --help' for more information on a command.
362366
{{- end}}
367+
{{- if displayHelpLink .}}
368+
To get more help with docker, check out guides at https://docs.docker.com/go/guides.md
369+
{{- end}}
363370
`
364371

365372
var helpTemplate = `

0 commit comments

Comments
 (0)