diff --git a/pkg/cli/add_command.go b/pkg/cli/add_command.go index f9a320deb4..81bc42cc48 100644 --- a/pkg/cli/add_command.go +++ b/pkg/cli/add_command.go @@ -359,7 +359,7 @@ func addWorkflowWithTracking(workflow *WorkflowSpec, number int, verbose bool, q } if verbose { - fmt.Fprintln(os.Stderr, "Locating workflow components...") + fmt.Fprintln(os.Stderr, console.FormatInfoMessage("Locating workflow components...")) } workflowPath := workflow.WorkflowPath diff --git a/pkg/cli/add_interactive_engine.go b/pkg/cli/add_interactive_engine.go index 6592a763b3..18f44ff5bd 100644 --- a/pkg/cli/add_interactive_engine.go +++ b/pkg/cli/add_interactive_engine.go @@ -72,7 +72,7 @@ func (c *AddInteractiveConfig) selectAIEngineAndKey() error { // If engine is already overridden, skip selection if c.EngineOverride != "" { - fmt.Fprintf(os.Stderr, "Using coding agent: %s\n", c.EngineOverride) + fmt.Fprintln(os.Stderr, console.FormatInfoMessage(fmt.Sprintf("Using coding agent: %s", c.EngineOverride))) return c.collectAPIKey(c.EngineOverride) } @@ -218,9 +218,9 @@ func (c *AddInteractiveConfig) collectGenericAPIKey(opt *constants.EngineOption) } fmt.Fprintln(os.Stderr, "") - fmt.Fprintf(os.Stderr, "%s requires an API key.\n", opt.Label) + fmt.Fprintln(os.Stderr, console.FormatInfoMessage(fmt.Sprintf("%s requires an API key.", opt.Label))) fmt.Fprintln(os.Stderr, "") - fmt.Fprintln(os.Stderr, "Get your API key from:") + fmt.Fprintln(os.Stderr, console.FormatInfoMessage("Get your API key from:")) fmt.Fprintln(os.Stderr, console.FormatCommandMessage(fmt.Sprintf(" %s", opt.KeyURL))) fmt.Fprintln(os.Stderr, "") diff --git a/pkg/cli/add_interactive_git.go b/pkg/cli/add_interactive_git.go index 516afeefa1..a60aaed824 100644 --- a/pkg/cli/add_interactive_git.go +++ b/pkg/cli/add_interactive_git.go @@ -59,9 +59,9 @@ func (c *AddInteractiveConfig) applyChanges(ctx context.Context, workflowFiles, if err := c.addRepositorySecret(secretName, secretValue); err != nil { fmt.Fprintln(os.Stderr, console.FormatErrorMessage(fmt.Sprintf("Failed to add secret: %v", err))) fmt.Fprintln(os.Stderr, "") - fmt.Fprintln(os.Stderr, "Please add the secret manually:") - fmt.Fprintln(os.Stderr, " 1. Go to your repository Settings → Secrets and variables → Actions") - fmt.Fprintf(os.Stderr, " 2. Click 'New repository secret' and add '%s'\n", secretName) + fmt.Fprintln(os.Stderr, console.FormatInfoMessage("Please add the secret manually:")) + fmt.Fprintln(os.Stderr, console.FormatInfoMessage(" 1. Go to your repository Settings → Secrets and variables → Actions")) + fmt.Fprintln(os.Stderr, console.FormatInfoMessage(fmt.Sprintf(" 2. Click 'New repository secret' and add '%s'", secretName))) return fmt.Errorf("failed to add secret: %w", err) } diff --git a/pkg/cli/add_interactive_orchestrator.go b/pkg/cli/add_interactive_orchestrator.go index ce002f2b64..075b1e62d0 100644 --- a/pkg/cli/add_interactive_orchestrator.go +++ b/pkg/cli/add_interactive_orchestrator.go @@ -179,9 +179,9 @@ func (c *AddInteractiveConfig) determineFilesToAdd() (workflowFiles []string, in } fmt.Fprintln(os.Stderr, "") - fmt.Fprintln(os.Stderr, "The following workflow files will be added:") + fmt.Fprintln(os.Stderr, console.FormatInfoMessage("The following workflow files will be added:")) for _, f := range workflowFiles { - fmt.Fprintf(os.Stderr, " • .github/workflows/%s\n", f) + fmt.Fprintln(os.Stderr, console.FormatInfoMessage(fmt.Sprintf(" • .github/workflows/%s", f))) } return workflowFiles, initFiles, nil @@ -229,7 +229,7 @@ func (c *AddInteractiveConfig) showFinalInstructions() { // Show summary with workflow name(s) if c.resolvedWorkflows != nil && len(c.resolvedWorkflows.Workflows) > 0 { wf := c.resolvedWorkflows.Workflows[0] - fmt.Fprintf(os.Stderr, "The workflow '%s' has been added to the repository and will now run automatically.\n", wf.Spec.WorkflowName) + fmt.Fprintln(os.Stderr, console.FormatSuccessMessage(fmt.Sprintf("The workflow '%s' has been added to the repository and will now run automatically.", wf.Spec.WorkflowName))) c.showWorkflowDescriptions() } diff --git a/pkg/cli/add_interactive_secrets.go b/pkg/cli/add_interactive_secrets.go index 02130a3b5e..4d5115ce17 100644 --- a/pkg/cli/add_interactive_secrets.go +++ b/pkg/cli/add_interactive_secrets.go @@ -5,6 +5,7 @@ import ( "os" "strings" + "github.com/github/gh-aw/pkg/console" "github.com/github/gh-aw/pkg/constants" "github.com/github/gh-aw/pkg/workflow" ) @@ -34,7 +35,7 @@ func (c *AddInteractiveConfig) checkExistingSecrets() error { } if c.Verbose && len(c.existingSecrets) > 0 { - fmt.Fprintf(os.Stderr, "Found %d existing repository secret(s)\n", len(c.existingSecrets)) + fmt.Fprintln(os.Stderr, console.FormatInfoMessage(fmt.Sprintf("Found %d existing repository secret(s)", len(c.existingSecrets)))) } return nil diff --git a/pkg/cli/add_interactive_workflow.go b/pkg/cli/add_interactive_workflow.go index a353e3a46d..1b89e6b5b5 100644 --- a/pkg/cli/add_interactive_workflow.go +++ b/pkg/cli/add_interactive_workflow.go @@ -46,17 +46,17 @@ func (c *AddInteractiveConfig) checkStatusAndOfferRun(ctx context.Context) error parsed, _ := parseWorkflowSpec(c.WorkflowSpecs[0]) if parsed != nil { if c.Verbose { - fmt.Fprintf(os.Stderr, "Checking workflow status (attempt %d/5) for: %s\n", i+1, parsed.WorkflowName) + fmt.Fprintln(os.Stderr, console.FormatInfoMessage(fmt.Sprintf("Checking workflow status (attempt %d/5) for: %s", i+1, parsed.WorkflowName))) } // Check if workflow is in status statuses, err := getWorkflowStatuses(parsed.WorkflowName, c.RepoOverride, c.Verbose) if err != nil { if c.Verbose { - fmt.Fprintf(os.Stderr, "Status check error: %v\n", err) + fmt.Fprintln(os.Stderr, console.FormatWarningMessage(fmt.Sprintf("Status check error: %v", err))) } } else if len(statuses) > 0 { if c.Verbose { - fmt.Fprintf(os.Stderr, "Found %d workflow(s) matching pattern\n", len(statuses)) + fmt.Fprintln(os.Stderr, console.FormatInfoMessage(fmt.Sprintf("Found %d workflow(s) matching pattern", len(statuses)))) } workflowFound = true break @@ -73,7 +73,7 @@ func (c *AddInteractiveConfig) checkStatusAndOfferRun(ctx context.Context) error if !workflowFound { fmt.Fprintln(os.Stderr, console.FormatWarningMessage("Could not verify workflow status.")) - fmt.Fprintf(os.Stderr, "You can check status with: %s status\n", string(constants.CLIExtensionPrefix)) + fmt.Fprintln(os.Stderr, console.FormatInfoMessage(fmt.Sprintf("You can check status with: %s status", string(constants.CLIExtensionPrefix)))) c.showFinalInstructions() return nil } @@ -138,7 +138,7 @@ func (c *AddInteractiveConfig) checkStatusAndOfferRun(ctx context.Context) error fmt.Fprintln(os.Stderr, "") fmt.Fprintln(os.Stderr, console.FormatSuccessMessage("Workflow triggered successfully!")) fmt.Fprintln(os.Stderr, "") - fmt.Fprintf(os.Stderr, "🔗 View workflow run: %s\n", runInfo.URL) + fmt.Fprintln(os.Stderr, console.FormatInfoMessage(fmt.Sprintf("🔗 View workflow run: %s", runInfo.URL))) } } } @@ -159,20 +159,20 @@ func getWorkflowStatuses(pattern, repoOverride string, verbose bool) ([]Workflow } if verbose { - fmt.Fprintf(os.Stderr, "Running: gh %s\n", strings.Join(args, " ")) + fmt.Fprintln(os.Stderr, console.FormatVerboseMessage(fmt.Sprintf("Running: gh %s", strings.Join(args, " ")))) } output, err := workflow.RunGH("Checking workflow status...", args...) if err != nil { if verbose { - fmt.Fprintf(os.Stderr, "gh workflow list failed: %v\n", err) + fmt.Fprintln(os.Stderr, console.FormatWarningMessage(fmt.Sprintf("gh workflow list failed: %v", err))) } return nil, err } if verbose { - fmt.Fprintf(os.Stderr, "gh workflow list output: %s\n", string(output)) - fmt.Fprintf(os.Stderr, "Looking for workflow with filename containing: %s\n", pattern) + fmt.Fprintln(os.Stderr, console.FormatVerboseMessage(fmt.Sprintf("gh workflow list output: %s", string(output)))) + fmt.Fprintln(os.Stderr, console.FormatVerboseMessage(fmt.Sprintf("Looking for workflow with filename containing: %s", pattern))) } // Check if any workflow path contains the pattern @@ -181,13 +181,13 @@ func getWorkflowStatuses(pattern, repoOverride string, verbose bool) ([]Workflow // We check if the path contains the pattern if strings.Contains(string(output), pattern+".lock.yml") || strings.Contains(string(output), pattern+".md") { if verbose { - fmt.Fprintf(os.Stderr, "Workflow with filename '%s' found in workflow list\n", pattern) + fmt.Fprintln(os.Stderr, console.FormatVerboseMessage(fmt.Sprintf("Workflow with filename '%s' found in workflow list", pattern))) } return []WorkflowStatus{{Workflow: pattern}}, nil } if verbose { - fmt.Fprintf(os.Stderr, "Workflow with filename '%s' NOT found in workflow list\n", pattern) + fmt.Fprintln(os.Stderr, console.FormatVerboseMessage(fmt.Sprintf("Workflow with filename '%s' NOT found in workflow list", pattern))) } return nil, nil } diff --git a/pkg/cli/trial_command.go b/pkg/cli/trial_command.go index 9af4af6567..10a617b12f 100644 --- a/pkg/cli/trial_command.go +++ b/pkg/cli/trial_command.go @@ -751,8 +751,8 @@ func showTrialConfirmation(parsedSpecs []*WorkflowSpec, logicalRepoSlug, cloneRe workflowName := parsedSpecs[0].WorkflowName if repeatCount > 0 && autoMergePRs { fmt.Fprintf(os.Stderr, console.FormatInfoMessage(" %d. For each of %d executions:\n"), stepNum, repeatCount+1) - fmt.Fprintf(os.Stderr, " a. Execute %s\n", workflowName) - fmt.Fprintf(os.Stderr, " b. Auto-merge any pull requests created during execution\n") + fmt.Fprintln(os.Stderr, console.FormatInfoMessage(fmt.Sprintf(" a. Execute %s", workflowName))) + fmt.Fprintln(os.Stderr, console.FormatInfoMessage(" b. Auto-merge any pull requests created during execution")) } else if repeatCount > 0 { fmt.Fprintf(os.Stderr, console.FormatInfoMessage(" %d. Execute %s %d times\n"), stepNum, workflowName, repeatCount+1) } else if autoMergePRs { @@ -771,8 +771,8 @@ func showTrialConfirmation(parsedSpecs []*WorkflowSpec, logicalRepoSlug, cloneRe if repeatCount > 0 && autoMergePRs { fmt.Fprintf(os.Stderr, console.FormatInfoMessage(" %d. For each of %d executions:\n"), stepNum, repeatCount+1) - fmt.Fprintf(os.Stderr, " a. Execute: %s\n", workflowList) - fmt.Fprintf(os.Stderr, " b. Auto-merge any pull requests created during execution\n") + fmt.Fprintln(os.Stderr, console.FormatInfoMessage(fmt.Sprintf(" a. Execute: %s", workflowList))) + fmt.Fprintln(os.Stderr, console.FormatInfoMessage(" b. Auto-merge any pull requests created during execution")) } else if repeatCount > 0 { fmt.Fprintf(os.Stderr, console.FormatInfoMessage(" %d. Execute %d times: %s\n"), stepNum, repeatCount+1, workflowList) } else if autoMergePRs { diff --git a/pkg/cli/trial_dry_run_test.go b/pkg/cli/trial_dry_run_test.go index 22d407b93e..226f32a4ca 100644 --- a/pkg/cli/trial_dry_run_test.go +++ b/pkg/cli/trial_dry_run_test.go @@ -269,7 +269,7 @@ func TestDryRunNoActualAPICallsForCreate(t *testing.T) { output := buf.String() // Should not error - assert.NoError(t, err, "Dry-run should not error") + require.NoError(t, err, "Dry-run should not error") // Should indicate that it would create the repository if strings.Contains(output, "exists") { @@ -333,7 +333,7 @@ func TestDryRunForceDeleteBehavior(t *testing.T) { buf.ReadFrom(r) output := buf.String() - assert.NoError(t, err, "Should not error in dry-run mode") + require.NoError(t, err, "Should not error in dry-run mode") assert.Contains(t, output, "[DRY RUN]", "Should show dry-run prefix") }) }