RunGHContextWithHost executes a gh CLI command with context support, a spinner, and an explicit GitHub host.
(ctx context.Context, spinnerMessage string, host string, args ...string)
| 212 | // RunGHContextWithHost executes a gh CLI command with context support, a spinner, |
| 213 | // and an explicit GitHub host. |
| 214 | func RunGHContextWithHost(ctx context.Context, spinnerMessage string, host string, args ...string) ([]byte, error) { |
| 215 | cmd := ExecGHContext(ctx, args...) |
| 216 | SetGHHostEnv(cmd, host) |
| 217 | |
| 218 | if tty.IsStderrTerminal() { |
| 219 | spinner := console.NewSpinner(spinnerMessage) |
| 220 | spinner.Start() |
| 221 | output, err := cmd.Output() |
| 222 | err = enrichGHError(err) |
| 223 | spinner.Stop() |
| 224 | return output, err |
| 225 | } |
| 226 | |
| 227 | output, err := cmd.Output() |
| 228 | return output, enrichGHError(err) |
| 229 | } |
| 230 | |
| 231 | // SetGHHostEnv sets the GH_HOST environment variable on the command for non-github.com hosts. |
| 232 | // This is needed for GitHub Enterprise Server (GHES) and Proxima (data residency) instances |
no test coverage detected