runGHWithSpinnerContext executes a gh CLI command with context support, a spinner, and returns the output. This is the core implementation for all RunGH* functions.
(ctx context.Context, spinnerMessage string, combined bool, args ...string)
| 115 | // runGHWithSpinnerContext executes a gh CLI command with context support, a spinner, |
| 116 | // and returns the output. This is the core implementation for all RunGH* functions. |
| 117 | func runGHWithSpinnerContext(ctx context.Context, spinnerMessage string, combined bool, args ...string) ([]byte, error) { |
| 118 | cmd := ExecGHContext(ctx, args...) |
| 119 | |
| 120 | // Show spinner in interactive terminals |
| 121 | if tty.IsStderrTerminal() { |
| 122 | spinner := console.NewSpinner(spinnerMessage) |
| 123 | spinner.Start() |
| 124 | var output []byte |
| 125 | var err error |
| 126 | if combined { |
| 127 | output, err = cmd.CombinedOutput() |
| 128 | } else { |
| 129 | output, err = cmd.Output() |
| 130 | err = enrichGHError(err) |
| 131 | } |
| 132 | spinner.Stop() |
| 133 | return output, err |
| 134 | } |
| 135 | |
| 136 | if combined { |
| 137 | return cmd.CombinedOutput() |
| 138 | } |
| 139 | output, err := cmd.Output() |
| 140 | return output, enrichGHError(err) |
| 141 | } |
| 142 | |
| 143 | // RunGH executes a gh CLI command with a spinner and returns the stdout output. |
| 144 | // The spinner is shown in interactive terminals to provide feedback during network operations. |
no test coverage detected