Skip to content

[plan] Migrate workflow commands (run, status, logs, audit) to RunE #5302

@github-actions

Description

@github-actions

Objective

Migrate core workflow operation commands from Run to RunE for idiomatic error handling.

Context

This is Batch 2 of 5 in the Run→RunE migration. These are the most frequently used commands for workflow management.

Parent Issue: #5300
Depends on: Batch 1 (error formatter setup) must be completed first

Commands to Migrate

  1. run - Execute workflows
  2. status - Check workflow status
  3. logs - Download and view workflow logs
  4. audit - Investigate workflow failures

Approach

For each command file:

  1. Change Run: to RunE:
  2. Remove os.Exit(1) calls
  3. Return errors directly instead of handling them inline
  4. Keep console.FormatErrorMessage for now (handled by root command)

Pattern Example

Before:

Run: func(cmd *cobra.Command, args []string) {
    if err := cli.RunWorkflow(...); err != nil {
        fmt.Fprintln(os.Stderr, console.FormatErrorMessage(err.Error()))
        os.Exit(1)
    }
}

After:

RunE: func(cmd *cobra.Command, args []string) error {
    return cli.RunWorkflow(...)
}

Files to Modify

  • pkg/cli/run_command.go
  • pkg/cli/status_command.go
  • pkg/cli/logs.go
  • pkg/cli/audit_command.go

Acceptance Criteria

  • All four command files use RunE instead of Run
  • No os.Exit(1) calls in any of these commands
  • Errors propagate correctly to Cobra
  • Error messages remain user-friendly
  • All existing tests pass
  • Manual testing confirms correct exit codes

Testing

# Build and test each command
make build

# Test run command
./gh-aw run --help
./gh-aw run nonexistent-workflow  # Should error gracefully

# Test status command
./gh-aw status --help
./gh-aw status

# Test logs command
./gh-aw logs --help
./gh-aw logs

# Test audit command
./gh-aw audit --help
./gh-aw audit 12345

# Run test suite
make test-unit

Related to #5300

AI generated by Plan Command for #5282

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions