@@ -21,6 +21,8 @@ import (
21
21
"github.com/spf13/pflag"
22
22
)
23
23
24
+ const experimentalCommandHint = `Experimental commands and flags are hidden. Set BUILDX_EXPERIMENTAL=1 to show them.`
25
+
24
26
func NewRootCmd (name string , isPlugin bool , dockerCli * command.DockerCli ) * cobra.Command {
25
27
var opt rootOptions
26
28
cmd := & cobra.Command {
@@ -29,6 +31,12 @@ func NewRootCmd(name string, isPlugin bool, dockerCli *command.DockerCli) *cobra
29
31
Use : name ,
30
32
Annotations : map [string ]string {
31
33
annotation .CodeDelimiter : `"` ,
34
+ "additionalHelp" : func () string {
35
+ if ! confutil .IsExperimental () {
36
+ return experimentalCommandHint
37
+ }
38
+ return ""
39
+ }(),
32
40
},
33
41
CompletionOptions : cobra.CompletionOptions {
34
42
HiddenDefaultCmd : true ,
@@ -72,6 +80,9 @@ func NewRootCmd(name string, isPlugin bool, dockerCli *command.DockerCli) *cobra
72
80
cmd .TraverseChildren = true
73
81
cmd .DisableFlagsInUseLine = true
74
82
cli .DisableFlagsInUseLine (cmd )
83
+ if ! confutil .IsExperimental () {
84
+ cmd .SetHelpTemplate (cmd .HelpTemplate () + "\n " + experimentalCommandHint + "\n " )
85
+ }
75
86
}
76
87
77
88
logrus .SetFormatter (& logutil.Formatter {})
@@ -84,10 +95,6 @@ func NewRootCmd(name string, isPlugin bool, dockerCli *command.DockerCli) *cobra
84
95
"using default config store" ,
85
96
))
86
97
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
-
91
98
addCommands (cmd , & opt , dockerCli )
92
99
return cmd
93
100
}
0 commit comments