Skip to content

Apply console formatting to top 5 CLI error-heavy files#12352

Closed
Copilot wants to merge 5 commits intomainfrom
copilot/apply-console-formatting-to-cli-files
Closed

Apply console formatting to top 5 CLI error-heavy files#12352
Copilot wants to merge 5 commits intomainfrom
copilot/apply-console-formatting-to-cli-files

Conversation

Copy link
Contributor

Copilot AI commented Jan 28, 2026

Problem

Four CLI files contained 126 unformatted error and informational messages, representing 25% of all unformatted CLI output in the codebase. Raw fmt.Fprintf/fmt.Fprintln calls lack consistent styling and color coding.

Changes

Before:

fmt.Fprintln(os.Stderr, "GitHub Actions is not enabled on this repository.")
fmt.Fprintln(os.Stderr, "To enable GitHub Actions:")
fmt.Fprintln(os.Stderr, "  1. Go to your repository on GitHub")

After:

fmt.Fprintln(os.Stderr, console.FormatErrorMessage("GitHub Actions is not enabled on this repository."))
fmt.Fprintln(os.Stderr, console.FormatInfoMessage("To enable GitHub Actions:"))
fmt.Fprintln(os.Stderr, console.FormatInfoMessage("  1. Go to your repository on GitHub"))

Files Updated

  • trial_command.go (4 lines): Workflow execution step descriptions
  • add_command.go (5 lines): Help instructions and command examples
  • audit_report_render.go (42 lines): Report sections (missing tools, MCP failures, errors/warnings, firewall analysis, findings, recommendations)
  • add_interactive.go (28 lines): Interactive wizard messages (auth, repo setup, Actions enablement, API key instructions)
  • init.go: Already formatted, no changes needed

Message Type Mapping

  • Error messages → console.FormatErrorMessage()
  • Warnings → console.FormatWarningMessage()
  • Informational text → console.FormatInfoMessage()
  • Success confirmations → console.FormatSuccessMessage()
  • Command examples → console.FormatCommandMessage()

Blank spacing lines ("") left unformatted to preserve report structure readability.

Original prompt

This section details on the original issue you should resolve

<issue_title>[Code Quality] Apply console formatting to top 5 CLI error-heavy files</issue_title>
<issue_description>### Description

Apply console.FormatErrorMessage() formatting to the top 5 CLI files with highest unformatted error counts. These files contain 388 unformatted errors representing 25% of all unformatted errors in the codebase.

Files to Update (Priority Order)

File Unformatted Errors Impact
pkg/cli/add_interactive.go 107 Interactive wizard - critical UX
pkg/cli/init.go 100 First-time setup - critical onboarding
pkg/cli/add_command.go 72 Workflow creation - common operation
pkg/cli/audit_report_render.go 61 Audit reports - troubleshooting tool
pkg/cli/trial_command.go 48 Workflow testing - developer workflow

Pattern to Replace

// ❌ BEFORE - Raw error output
if err != nil {
    fmt.Fprintln(os.Stderr, err)
    return err
}

// ✅ AFTER - Console formatted error
if err != nil {
    fmt.Fprintln(os.Stderr, console.FormatErrorMessage(err.Error()))
    return err
}

Success Criteria

  • Update all error outputs in add_interactive.go (107 errors)
  • Update all error outputs in init.go (100 errors)
  • Update all error outputs in add_command.go (72 errors)
  • Update all error outputs in audit_report_render.go (61 errors)
  • Update all error outputs in trial_command.go (48 errors)
  • All fmt.Fprintln(os.Stderr, err)fmt.Fprintln(os.Stderr, console.FormatErrorMessage(err.Error()))
  • Verify no stdout error outputs remain
  • Test commands manually to verify formatting

Impact

High - 388 errors (25% of all unformatted errors) will have proper console formatting, providing immediate user experience improvement.

Source

Extracted from Error Experience Engineering Deep Dive discussion githubnext/gh-aw#12265

Analysis: Only 4.4% (69/1,581) of error output sites use proper console formatting. Top 5 files represent the highest-impact targets.

AI generated by Discussion Task Miner - Code Quality Improvement Agent

  • expires on Feb 11, 2026, 5:12 PM UTC

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 4 commits January 28, 2026 20:07
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Apply console formatting to top 5 CLI error-heavy files Apply console formatting to top 5 CLI error-heavy files Jan 28, 2026
Copilot AI requested a review from pelikhan January 28, 2026 20:23
@pelikhan pelikhan closed this Jan 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Code Quality] Apply console formatting to top 5 CLI error-heavy files

2 participants