CreateWorkflowInteractively prompts the user to build a workflow interactively
(ctx context.Context, workflowName string, verbose bool, force bool)
| 62 | |
| 63 | // CreateWorkflowInteractively prompts the user to build a workflow interactively |
| 64 | func CreateWorkflowInteractively(ctx context.Context, workflowName string, verbose bool, force bool) error { |
| 65 | interactiveLog.Printf("Starting interactive workflow creation: workflowName=%s, force=%v", workflowName, force) |
| 66 | |
| 67 | // Assert this function is not running in automated unit tests |
| 68 | if os.Getenv("GO_TEST_MODE") == "true" || os.Getenv("CI") != "" { |
| 69 | return errors.New("interactive workflow creation cannot be used in automated tests or CI environments") |
| 70 | } |
| 71 | |
| 72 | if verbose { |
| 73 | fmt.Fprintln(os.Stderr, console.FormatInfoMessage("Starting interactive workflow creation...")) |
| 74 | } |
| 75 | |
| 76 | builder := &InteractiveWorkflowBuilder{ |
| 77 | ctx: ctx, |
| 78 | WorkflowName: workflowName, |
| 79 | } |
| 80 | |
| 81 | // If using default workflow name, prompt for a better one |
| 82 | if workflowName == "my-workflow" { |
| 83 | if err := builder.promptForWorkflowName(); err != nil { |
| 84 | return fmt.Errorf("failed to get workflow name: %w", err) |
| 85 | } |
| 86 | } |
| 87 | |
| 88 | // Run through the interactive prompts organized by groups |
| 89 | if err := builder.promptForConfiguration(); err != nil { |
| 90 | return fmt.Errorf("failed to get workflow configuration: %w", err) |
| 91 | } |
| 92 | |
| 93 | // Generate the workflow |
| 94 | if err := builder.generateWorkflow(force); err != nil { |
| 95 | return fmt.Errorf("failed to generate workflow: %w", err) |
| 96 | } |
| 97 | |
| 98 | // Compile the workflow |
| 99 | if err := builder.compileWorkflow(ctx, verbose); err != nil { |
| 100 | return fmt.Errorf("failed to compile workflow: %w", err) |
| 101 | } |
| 102 | |
| 103 | return nil |
| 104 | } |
| 105 | |
| 106 | // promptForWorkflowName asks the user for a workflow name |
| 107 | func (b *InteractiveWorkflowBuilder) promptForWorkflowName() error { |