@@ -35,6 +35,7 @@ func setupCommonRootCommand(rootCmd *cobra.Command) (*cliflags.ClientOptions, *p
3535 cobra .AddTemplateFunc ("vendorAndVersion" , vendorAndVersion )
3636 cobra .AddTemplateFunc ("invalidPluginReason" , invalidPluginReason )
3737 cobra .AddTemplateFunc ("isPlugin" , isPlugin )
38+ cobra .AddTemplateFunc ("isExperimental" , isExperimental )
3839 cobra .AddTemplateFunc ("decoratedName" , decoratedName )
3940
4041 rootCmd .SetUsageTemplate (usageTemplate )
@@ -191,6 +192,19 @@ var helpCommand = &cobra.Command{
191192 },
192193}
193194
195+ func isExperimental (cmd * cobra.Command ) bool {
196+ if _ , ok := cmd .Annotations ["experimentalCLI" ]; ok {
197+ return true
198+ }
199+ var experimental bool
200+ cmd .VisitParents (func (cmd * cobra.Command ) {
201+ if _ , ok := cmd .Annotations ["experimentalCLI" ]; ok {
202+ experimental = true
203+ }
204+ })
205+ return experimental
206+ }
207+
194208func isPlugin (cmd * cobra.Command ) bool {
195209 return cmd .Annotations [pluginmanager .CommandAnnotationPlugin ] == "true"
196210}
@@ -286,7 +300,16 @@ var usageTemplate = `Usage:
286300{{- if .HasSubCommands}} {{ .CommandPath}}{{- if .HasAvailableFlags}} [OPTIONS]{{end}} COMMAND{{end}}
287301
288302{{if ne .Long ""}}{{ .Long | trim }}{{ else }}{{ .Short | trim }}{{end}}
303+ {{- if isExperimental .}}
304+
305+ EXPERIMENTAL:
306+ {{.CommandPath}} is an experimental feature.
307+ Experimental features provide early access to product functionality. These
308+ features may change between releases without warning, or can be removed from a
309+ future release. Learn more about experimental features in our documentation:
310+ https://docs.docker.com/go/experimental/
289311
312+ {{- end}}
290313{{- if gt .Aliases 0}}
291314
292315Aliases:
0 commit comments