Show experimental flags and subcommands if enabled

Signed-off-by: John Stephens <johnstep@docker.com>
This commit is contained in:
John Stephens 2016-11-11 17:43:06 -08:00
parent 076bfc0647
commit 13d6a1bb67
1 changed files with 8 additions and 4 deletions

View File

@ -126,9 +126,11 @@ func dockerPreRun(opts *cliflags.ClientOptions) {
func hideUnsupportedFeatures(cmd *cobra.Command, clientVersion string, hasExperimental bool) {
cmd.Flags().VisitAll(func(f *pflag.Flag) {
// hide experimental flags
if !hasExperimental {
if _, ok := f.Annotations["experimental"]; ok {
f.Hidden = true
}
}
// hide flags not supported by the server
if flagVersion, ok := f.Annotations["version"]; ok && len(flagVersion) == 1 && versions.LessThan(clientVersion, flagVersion[0]) {
@ -139,9 +141,11 @@ func hideUnsupportedFeatures(cmd *cobra.Command, clientVersion string, hasExperi
for _, subcmd := range cmd.Commands() {
// hide experimental subcommands
if !hasExperimental {
if _, ok := subcmd.Tags["experimental"]; ok {
subcmd.Hidden = true
}
}
// hide subcommands not supported by the server
if subcmdVersion, ok := subcmd.Tags["version"]; ok && versions.LessThan(clientVersion, subcmdVersion) {