NewExperimentsCommand creates the experiments command with its subcommands.
()
| 87 | |
| 88 | // NewExperimentsCommand creates the experiments command with its subcommands. |
| 89 | func NewExperimentsCommand() *cobra.Command { |
| 90 | cmd := &cobra.Command{ |
| 91 | Use: "experiments", |
| 92 | Hidden: true, |
| 93 | Short: "Explore ongoing experiments in the repository", |
| 94 | Long: `Explore ongoing experiments in the repository. |
| 95 | |
| 96 | Experiments are tracked via git branches with the "experiments/" prefix (e.g., |
| 97 | experiments/my-workflow). Each branch stores a state.json file written by the |
| 98 | workflow's pick_experiment step, containing variant counts and run history. |
| 99 | |
| 100 | Available subcommands: |
| 101 | - list - List all experiment workflow branches (default) |
| 102 | - analyze - Analyze a specific experiment workflow in detail`, |
| 103 | Example: ` ` + string(constants.CLIExtensionPrefix) + ` experiments # List all experiments (default) |
| 104 | ` + string(constants.CLIExtensionPrefix) + ` experiments list # List all experiments |
| 105 | ` + string(constants.CLIExtensionPrefix) + ` experiments list --json # Output in JSON format |
| 106 | ` + string(constants.CLIExtensionPrefix) + ` experiments analyze my-workflow # Analyze experiments/my-workflow |
| 107 | ` + string(constants.CLIExtensionPrefix) + ` experiments analyze my-workflow --json # Analyze in JSON format`, |
| 108 | RunE: func(cmd *cobra.Command, args []string) error { |
| 109 | jsonOutput, _ := cmd.Flags().GetBool("json") |
| 110 | repoOverride, _ := cmd.Flags().GetString("repo") |
| 111 | return RunExperimentsList(ExperimentsListConfig{ |
| 112 | RepoOverride: repoOverride, |
| 113 | JSONOutput: jsonOutput, |
| 114 | }) |
| 115 | }, |
| 116 | } |
| 117 | |
| 118 | addJSONFlag(cmd) |
| 119 | addRepoFlag(cmd) |
| 120 | |
| 121 | cmd.AddCommand(NewExperimentsListSubcommand()) |
| 122 | cmd.AddCommand(NewExperimentsAnalyzeSubcommand()) |
| 123 | |
| 124 | return cmd |
| 125 | } |
| 126 | |
| 127 | // NewExperimentsListSubcommand creates the experiments list subcommand. |
| 128 | func NewExperimentsListSubcommand() *cobra.Command { |