@@ -21,6 +21,8 @@ import (
2121 "github.com/spf13/pflag"
2222)
2323
24+ const experimentalCommandHint = `Experimental commands and flags are hidden. Set BUILDX_EXPERIMENTAL=1 to show them.`
25+
2426func NewRootCmd (name string , isPlugin bool , dockerCli * command.DockerCli ) * cobra.Command {
2527 var opt rootOptions
2628 cmd := & cobra.Command {
@@ -29,6 +31,12 @@ func NewRootCmd(name string, isPlugin bool, dockerCli *command.DockerCli) *cobra
2931 Use : name ,
3032 Annotations : map [string ]string {
3133 annotation .CodeDelimiter : `"` ,
34+ "additionalHelp" : func () string {
35+ if ! confutil .IsExperimental () {
36+ return experimentalCommandHint
37+ }
38+ return ""
39+ }(),
3240 },
3341 CompletionOptions : cobra.CompletionOptions {
3442 HiddenDefaultCmd : true ,
@@ -72,6 +80,9 @@ func NewRootCmd(name string, isPlugin bool, dockerCli *command.DockerCli) *cobra
7280 cmd .TraverseChildren = true
7381 cmd .DisableFlagsInUseLine = true
7482 cli .DisableFlagsInUseLine (cmd )
83+ if ! confutil .IsExperimental () {
84+ cmd .SetHelpTemplate (cmd .HelpTemplate () + "\n " + experimentalCommandHint + "\n " )
85+ }
7586 }
7687
7788 logrus .SetFormatter (& logutil.Formatter {})
@@ -84,10 +95,6 @@ func NewRootCmd(name string, isPlugin bool, dockerCli *command.DockerCli) *cobra
8495 "using default config store" ,
8596 ))
8697
87- if ! confutil .IsExperimental () {
88- cmd .SetHelpTemplate (cmd .HelpTemplate () + "\n Experimental commands and flags are hidden. Set BUILDX_EXPERIMENTAL=1 to show them.\n " )
89- }
90-
9198 addCommands (cmd , & opt , dockerCli )
9299 return cmd
93100}
0 commit comments