(dockerCli command.Cli, cmd *cobra.Command)
| 244 | } |
| 245 | |
| 246 | func setHelpFunc(dockerCli command.Cli, cmd *cobra.Command) { |
| 247 | defaultHelpFunc := cmd.HelpFunc() |
| 248 | cmd.SetHelpFunc(func(ccmd *cobra.Command, args []string) { |
| 249 | if err := pluginmanager.AddPluginCommandStubs(dockerCli, ccmd.Root()); err != nil { |
| 250 | ccmd.Println(err) |
| 251 | return |
| 252 | } |
| 253 | |
| 254 | if len(args) >= 1 { |
| 255 | err := tryRunPluginHelp(dockerCli, ccmd, args) |
| 256 | if err == nil { |
| 257 | return |
| 258 | } |
| 259 | if !errdefs.IsNotFound(err) { |
| 260 | ccmd.Println(err) |
| 261 | return |
| 262 | } |
| 263 | } |
| 264 | |
| 265 | // FIXME(thaJeztah): need a better way for this; hiding the command here, so that it's present" by default for generating docs etc. |
| 266 | if c, _, err := ccmd.Find([]string{"buildx"}); c == nil || err != nil { |
| 267 | if b, _, _ := ccmd.Find([]string{"bake"}); b != nil { |
| 268 | b.Hidden = true |
| 269 | } |
| 270 | } |
| 271 | if err := isSupported(ccmd, dockerCli); err != nil { |
| 272 | ccmd.Println(err) |
| 273 | return |
| 274 | } |
| 275 | hideUnsupportedFeatures(ccmd, dockerCli) |
| 276 | |
| 277 | defaultHelpFunc(ccmd, args) |
| 278 | }) |
| 279 | } |
| 280 | |
| 281 | // visitAll traverses all commands from the root. |
| 282 | func visitAll(root *cobra.Command, fns ...func(*cobra.Command)) { |
no test coverage detected
searching dependent graphs…