mirror of https://github.com/docker/cli.git
cli: print experimental message in usage output
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
0d11ef3056
commit
d9c36c2878
23
cli/cobra.go
23
cli/cobra.go
|
@ -35,6 +35,7 @@ func setupCommonRootCommand(rootCmd *cobra.Command) (*cliflags.ClientOptions, *p
|
||||||
cobra.AddTemplateFunc("vendorAndVersion", vendorAndVersion)
|
cobra.AddTemplateFunc("vendorAndVersion", vendorAndVersion)
|
||||||
cobra.AddTemplateFunc("invalidPluginReason", invalidPluginReason)
|
cobra.AddTemplateFunc("invalidPluginReason", invalidPluginReason)
|
||||||
cobra.AddTemplateFunc("isPlugin", isPlugin)
|
cobra.AddTemplateFunc("isPlugin", isPlugin)
|
||||||
|
cobra.AddTemplateFunc("isExperimental", isExperimental)
|
||||||
cobra.AddTemplateFunc("decoratedName", decoratedName)
|
cobra.AddTemplateFunc("decoratedName", decoratedName)
|
||||||
|
|
||||||
rootCmd.SetUsageTemplate(usageTemplate)
|
rootCmd.SetUsageTemplate(usageTemplate)
|
||||||
|
@ -191,6 +192,19 @@ var helpCommand = &cobra.Command{
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func isExperimental(cmd *cobra.Command) bool {
|
||||||
|
if _, ok := cmd.Annotations["experimentalCLI"]; ok {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
var experimental bool
|
||||||
|
cmd.VisitParents(func(cmd *cobra.Command) {
|
||||||
|
if _, ok := cmd.Annotations["experimentalCLI"]; ok {
|
||||||
|
experimental = true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return experimental
|
||||||
|
}
|
||||||
|
|
||||||
func isPlugin(cmd *cobra.Command) bool {
|
func isPlugin(cmd *cobra.Command) bool {
|
||||||
return cmd.Annotations[pluginmanager.CommandAnnotationPlugin] == "true"
|
return cmd.Annotations[pluginmanager.CommandAnnotationPlugin] == "true"
|
||||||
}
|
}
|
||||||
|
@ -286,7 +300,16 @@ var usageTemplate = `Usage:
|
||||||
{{- if .HasSubCommands}} {{ .CommandPath}}{{- if .HasAvailableFlags}} [OPTIONS]{{end}} COMMAND{{end}}
|
{{- if .HasSubCommands}} {{ .CommandPath}}{{- if .HasAvailableFlags}} [OPTIONS]{{end}} COMMAND{{end}}
|
||||||
|
|
||||||
{{if ne .Long ""}}{{ .Long | trim }}{{ else }}{{ .Short | trim }}{{end}}
|
{{if ne .Long ""}}{{ .Long | trim }}{{ else }}{{ .Short | trim }}{{end}}
|
||||||
|
{{- if isExperimental .}}
|
||||||
|
|
||||||
|
EXPERIMENTAL:
|
||||||
|
{{.CommandPath}} is an experimental feature.
|
||||||
|
Experimental features provide early access to product functionality. These
|
||||||
|
features may change between releases without warning, or can be removed from a
|
||||||
|
future release. Learn more about experimental features in our documentation:
|
||||||
|
https://docs.docker.com/go/experimental/
|
||||||
|
|
||||||
|
{{- end}}
|
||||||
{{- if gt .Aliases 0}}
|
{{- if gt .Aliases 0}}
|
||||||
|
|
||||||
Aliases:
|
Aliases:
|
||||||
|
|
Loading…
Reference in New Issue