confirmExecution asks the user to confirm workflow execution
(ctx context.Context, wf *WorkflowOption, inputs []string)
| 334 | |
| 335 | // confirmExecution asks the user to confirm workflow execution |
| 336 | func confirmExecution(ctx context.Context, wf *WorkflowOption, inputs []string) bool { |
| 337 | runInteractiveLog.Print("Requesting execution confirmation") |
| 338 | |
| 339 | var confirm bool |
| 340 | message := fmt.Sprintf("Run workflow '%s'?", wf.Name) |
| 341 | |
| 342 | if len(inputs) > 0 { |
| 343 | message = fmt.Sprintf("Run workflow '%s' with %d input(s)?", wf.Name, len(inputs)) |
| 344 | } |
| 345 | |
| 346 | form := huh.NewForm( |
| 347 | huh.NewGroup( |
| 348 | huh.NewConfirm(). |
| 349 | Title(message). |
| 350 | Affirmative("Yes, run it"). |
| 351 | Negative("No, cancel"). |
| 352 | Value(&confirm), |
| 353 | ), |
| 354 | ).WithTheme(styles.HuhTheme).WithAccessible(console.IsAccessibleMode()) |
| 355 | |
| 356 | if err := form.RunWithContext(ctx); err != nil { |
| 357 | runInteractiveLog.Printf("Confirmation failed: %v", err) |
| 358 | return false |
| 359 | } |
| 360 | |
| 361 | runInteractiveLog.Printf("User confirmed: %v", confirm) |
| 362 | return confirm |
| 363 | } |
| 364 | |
| 365 | // RunWorkflowOptions holds parameters for RunSpecificWorkflowInteractively. |
| 366 | type RunWorkflowOptions struct { |
no test coverage detected