Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/cli/add_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions pkg/cli/add_interactive_engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down Expand Up @@ -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, "")

Expand Down
6 changes: 3 additions & 3 deletions pkg/cli/add_interactive_git.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
6 changes: 3 additions & 3 deletions pkg/cli/add_interactive_orchestrator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
}

Expand Down
3 changes: 2 additions & 1 deletion pkg/cli/add_interactive_secrets.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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
Expand Down
22 changes: 11 additions & 11 deletions pkg/cli/add_interactive_workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}
Expand Down Expand Up @@ -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)))
}
}
}
Expand All @@ -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
Expand All @@ -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
}
8 changes: 4 additions & 4 deletions pkg/cli/trial_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions pkg/cli/trial_dry_run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand Down Expand Up @@ -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")
})
}
Expand Down