MCPcopy Create free account
hub / github.com/github/gh-aw / CreateWorkflowInteractively

Function CreateWorkflowInteractively

pkg/cli/interactive.go:64–104  ·  view source on GitHub ↗

CreateWorkflowInteractively prompts the user to build a workflow interactively

(ctx context.Context, workflowName string, verbose bool, force bool)

Source from the content-addressed store, hash-verified

62
63// CreateWorkflowInteractively prompts the user to build a workflow interactively
64func 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
107func (b *InteractiveWorkflowBuilder) promptForWorkflowName() error {

Calls 8

promptForWorkflowNameMethod · 0.95
generateWorkflowMethod · 0.95
compileWorkflowMethod · 0.95
FormatInfoMessageFunction · 0.92
GetenvMethod · 0.80
PrintfMethod · 0.45
ErrorfMethod · 0.45