HooksCommand returns the hidden subcommand that the Docker CLI invokes after command execution when the compose plugin has hooks configured. Docker Desktop is responsible for registering which commands trigger hooks in the docker CLI config; the handler gates all hints on the LogsTab feature flag be
()
| 159 | // in the docker CLI config; the handler gates all hints on the LogsTab |
| 160 | // feature flag before emitting them. |
| 161 | func HooksCommand() *cobra.Command { |
| 162 | return &cobra.Command{ |
| 163 | Use: metadata.HookSubcommandName, |
| 164 | Hidden: true, |
| 165 | // Override PersistentPreRunE to prevent the parent's PersistentPreRunE |
| 166 | // (plugin initialization) from running for hook invocations. |
| 167 | PersistentPreRunE: func(*cobra.Command, []string) error { return nil }, |
| 168 | RunE: func(cmd *cobra.Command, args []string) error { |
| 169 | return handleHook(cmd.Context(), args, cmd.OutOrStdout()) |
| 170 | }, |
| 171 | } |
| 172 | } |
| 173 | |
| 174 | func handleHook(ctx context.Context, args []string, w io.Writer) error { |
| 175 | if len(args) == 0 { |
nothing calls this directly
no test coverage detected