(ctx context.Context, args []string, w io.Writer)
| 172 | } |
| 173 | |
| 174 | func handleHook(ctx context.Context, args []string, w io.Writer) error { |
| 175 | if len(args) == 0 { |
| 176 | return nil |
| 177 | } |
| 178 | |
| 179 | var hookData hooks.Request |
| 180 | if err := json.Unmarshal([]byte(args[0]), &hookData); err != nil { |
| 181 | return nil |
| 182 | } |
| 183 | |
| 184 | hint, ok := hooksHints[hookData.RootCmd] |
| 185 | if !ok { |
| 186 | return nil |
| 187 | } |
| 188 | |
| 189 | if hint.checkFlags != nil && !hint.checkFlags(hookData.Flags) { |
| 190 | return nil |
| 191 | } |
| 192 | |
| 193 | if !logsTabEnabled(ctx) { |
| 194 | return nil |
| 195 | } |
| 196 | |
| 197 | var appID string |
| 198 | if hint.resolveProject { |
| 199 | appID = resolveAppID(ctx, hookData.Flags) |
| 200 | } |
| 201 | |
| 202 | enc := json.NewEncoder(w) |
| 203 | enc.SetEscapeHTML(false) |
| 204 | return enc.Encode(hooks.Response{ |
| 205 | Type: hooks.NextSteps, |
| 206 | Template: hint.template(appID), |
| 207 | }) |
| 208 | } |
no outgoing calls