@@ -393,23 +393,15 @@ func GetCommands() []cli.Command {
393393 },
394394 },
395395 {
396- Name : "docker" ,
397- Flags : cliutils .GetCommandFlags (cliutils .Docker ),
398- Usage : docker .GetDescription (),
399- HelpName : corecommon .CreateUsage ("docker" , docker .GetDescription (), docker .Usage ),
400- UsageText : docker .GetArguments (),
401- SkipFlagParsing : func () bool {
402- for i , arg := range os .Args {
403- // 'docker scan' isn't a docker client command. We won't skip its flags.
404- if arg == "docker" && len (os .Args ) > i + 1 && os .Args [i + 1 ] == "scan" {
405- return false
406- }
407- }
408- return true
409- }(),
410- BashComplete : corecommon .CreateBashCompletionFunc ("login" , "push" , "pull" , "scan" ),
411- Category : buildToolsCategory ,
412- Action : dockerCmd ,
396+ Name : "docker" ,
397+ Flags : cliutils .GetCommandFlags (cliutils .Docker ),
398+ Usage : docker .GetDescription (),
399+ HelpName : corecommon .CreateUsage ("docker" , docker .GetDescription (), docker .Usage ),
400+ UsageText : docker .GetArguments (),
401+ SkipFlagParsing : skipFlagParsingForDockerCmd (),
402+ BashComplete : corecommon .CreateBashCompletionFunc ("login" , "push" , "pull" , "scan" ),
403+ Category : buildToolsCategory ,
404+ Action : dockerCmd ,
413405 },
414406 {
415407 Name : "terraform-config" ,
@@ -453,6 +445,24 @@ func GetCommands() []cli.Command {
453445 return decorateWithFlagCapture (cmds )
454446}
455447
448+ func skipFlagParsingForDockerCmd () bool {
449+ isDockerScan := false
450+ hasHelpFlag := false
451+ for i , arg := range os .Args {
452+ if arg == "docker" && len (os .Args ) > i + 1 && os .Args [i + 1 ] == "scan" {
453+ isDockerScan = true
454+ }
455+ if arg == "--help" || arg == "-h" {
456+ hasHelpFlag = true
457+ }
458+ }
459+ // 'docker scan' isn't a docker client command. We won't skip its flags.
460+ if isDockerScan {
461+ return hasHelpFlag
462+ }
463+ return true
464+ }
465+
456466// decorateWithFlagCapture injects a Before hook into every command returned from this package,
457467// so we can capture user-provided flags consistently in one place for all build commands.
458468func decorateWithFlagCapture (cmds []cli.Command ) []cli.Command {
@@ -964,6 +974,9 @@ func loginCmd(c *cli.Context) error {
964974}
965975
966976func dockerScanCmd (c * cli.Context , imageTag string ) error {
977+ if show , err := cliutils .ShowGenericCmdHelpIfNeeded (c , c .Args (), securityCLI .DockerScanCmdHiddenName ); show || err != nil {
978+ return err
979+ }
967980 convertedCtx , err := components .ConvertContext (c , securityDocs .GetCommandFlags (securityDocs .DockerScan )... )
968981 if err != nil {
969982 return err
0 commit comments