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

Function NewOutcomesCommand

pkg/cli/outcomes_command.go:22–68  ·  view source on GitHub ↗

NewOutcomesCommand creates the outcomes command

()

Source from the content-addressed store, hash-verified

20
21// NewOutcomesCommand creates the outcomes command
22func NewOutcomesCommand() *cobra.Command {
23 cmd := &cobra.Command{
24 Use: "outcomes <run-id>",
25 Short: "Check what happened to a workflow run's safe outputs",
26 Long: `Evaluate the outcomes of safe output actions from a workflow run.
27
28For each safe output (created issue, PR, comment, label, etc.), checks the current
29state of the GitHub object to determine whether the action was accepted, rejected,
30ignored, or is still pending.
31
32This answers the question: "Did this workflow's actions actually help?"`,
33 Example: ` ` + string(constants.CLIExtensionPrefix) + ` outcomes 1234567890 # Check outcomes for a specific run
34 ` + string(constants.CLIExtensionPrefix) + ` outcomes 1234567890 --json # JSON output
35 ` + string(constants.CLIExtensionPrefix) + ` outcomes 1234567890 --repo o/r # Specify repository
36 ` + string(constants.CLIExtensionPrefix) + ` outcomes 1234567890 -v # Verbose output`,
37 Args: cobra.ExactArgs(1),
38 RunE: func(cmd *cobra.Command, args []string) error {
39 verbose, _ := cmd.Flags().GetBool("verbose")
40 jsonOutput, _ := cmd.Flags().GetBool("json")
41 repoOverride, _ := cmd.Flags().GetString("repo")
42 outputDir, _ := cmd.Flags().GetString("output")
43 outcomesDir, _ := cmd.Flags().GetString("outcomes-dir")
44
45 runID, err := strconv.ParseInt(args[0], 10, 64)
46 if err != nil {
47 return fmt.Errorf("invalid run ID %q: %w", args[0], err)
48 }
49
50 return RunOutcomes(OutcomesConfig{
51 RunID: runID,
52 Verbose: verbose,
53 JSONOutput: jsonOutput,
54 RepoOverride: repoOverride,
55 OutputDir: outputDir,
56 OutcomesDir: outcomesDir,
57 })
58 },
59 }
60
61 addJSONFlag(cmd)
62 addRepoFlag(cmd)
63 addOutputFlag(cmd, "")
64 cmd.Flags().String("outcomes-dir", "", "Write outcome JSONL to this directory for OTLP export")
65 cmd.AddCommand(NewOutcomesHistorySubcommand())
66
67 return cmd
68}
69
70// OutcomesConfig holds configuration for the outcomes command.
71type OutcomesConfig struct {

Calls 8

RunOutcomesFunction · 0.85
addJSONFlagFunction · 0.85
addRepoFlagFunction · 0.85
addOutputFlagFunction · 0.85
GetStringMethod · 0.65
ErrorfMethod · 0.45
StringMethod · 0.45