MCPcopy Create free account
hub / github.com/github/gh-aw / RunExperimentsList

Function RunExperimentsList

pkg/cli/experiments_command.go:190–230  ·  view source on GitHub ↗

RunExperimentsList lists all experiment branches.

(config ExperimentsListConfig)

Source from the content-addressed store, hash-verified

188
189// RunExperimentsList lists all experiment branches.
190func RunExperimentsList(config ExperimentsListConfig) error {
191 experimentsLog.Printf("Listing experiments: repo=%s, json=%v", config.RepoOverride, config.JSONOutput)
192
193 var experiments []ExperimentInfo
194 var err error
195
196 if config.RepoOverride != "" {
197 experiments, err = fetchRemoteExperiments(config.RepoOverride)
198 } else {
199 experiments, err = fetchLocalExperiments()
200 }
201
202 if err != nil {
203 fmt.Fprintln(os.Stderr, console.FormatErrorMessage(err.Error()))
204 return nil
205 }
206
207 if config.JSONOutput {
208 jsonBytes, err := json.MarshalIndent(experiments, "", " ")
209 if err != nil {
210 return fmt.Errorf("failed to marshal JSON: %w", err)
211 }
212 fmt.Fprintln(os.Stdout, string(jsonBytes))
213 return nil
214 }
215
216 if len(experiments) == 0 {
217 fmt.Fprintln(os.Stderr, console.FormatInfoMessage("No experiment workflow branches found (branches matching experiments/* pattern)."))
218 return nil
219 }
220
221 count := len(experiments)
222 if count == 1 {
223 fmt.Fprintln(os.Stderr, console.FormatSuccessMessage("Found 1 experiment workflow"))
224 } else {
225 fmt.Fprintln(os.Stderr, console.FormatSuccessMessage(fmt.Sprintf("Found %d experiment workflows", count)))
226 }
227 fmt.Fprint(os.Stderr, console.RenderStruct(experiments))
228
229 return nil
230}
231
232// RunExperimentsAnalyze analyzes a specific experiment branch.
233func RunExperimentsAnalyze(config ExperimentsAnalyzeConfig) error {

Callers 2

NewExperimentsCommandFunction · 0.85

Calls 9

FormatErrorMessageFunction · 0.92
FormatInfoMessageFunction · 0.92
FormatSuccessMessageFunction · 0.92
RenderStructFunction · 0.92
fetchRemoteExperimentsFunction · 0.85
fetchLocalExperimentsFunction · 0.85
PrintfMethod · 0.45
ErrorMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected