RunExperimentsList lists all experiment branches.
(config ExperimentsListConfig)
| 188 | |
| 189 | // RunExperimentsList lists all experiment branches. |
| 190 | func 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. |
| 233 | func RunExperimentsAnalyze(config ExperimentsAnalyzeConfig) error { |
no test coverage detected