MCPcopy Create free account
hub / github.com/cli/cli / NewCmdView

Function NewCmdView

pkg/cmd/run/view/view.go:108–218  ·  view source on GitHub ↗
(f *cmdutil.Factory, runF func(*ViewOptions) error)

Source from the content-addressed store, hash-verified

106}
107
108func NewCmdView(f *cmdutil.Factory, runF func(*ViewOptions) error) *cobra.Command {
109 opts := &ViewOptions{
110 IO: f.IOStreams,
111 HttpClient: f.HttpClient,
112 Prompter: f.Prompter,
113 Now: time.Now,
114 Browser: f.Browser,
115
116 InvokingAgent: f.InvokingAgent,
117 }
118
119 cmd := &cobra.Command{
120 Use: "view [<run-id>]",
121 Short: "View a summary of a workflow run",
122 Long: heredoc.Docf(`
123 View a summary of a workflow run.
124
125 Due to platform limitations, %[1]sgh%[1]s may not always be able to associate jobs with their
126 corresponding logs when using the primary method of fetching logs in zip format.
127
128 In such cases, %[1]sgh%[1]s will attempt to fetch logs for each job individually via the API.
129 This fallback is slower and more resource-intensive. If more than 25 job logs are missing,
130 the operation will fail with an error.
131
132 Additionally, due to similar platform constraints, some log lines may not be
133 associated with a specific step within a job. In these cases, the step name will
134 appear as %[1]sUNKNOWN STEP%[1]s in the log output.
135
136 This command shows a snapshot. To wait for the workflow runs of a pull request on %[1]sgithub.com%[1]s to
137 finish, use %[1]sgh event listen%[1]s with the
138 %[1]scom.github.pull_request.check_suite.status.changed.v1%[1]s event instead of polling this command. Each
139 check suite, such as a workflow run, sends its own event when it completes. Changes made before the listener
140 starts are not reported, so read the checks once it is listening.
141 `, "`", maxAPILogFetchers),
142 Args: cobra.MaximumNArgs(1),
143 Example: heredoc.Doc(`
144 # Interactively select a run to view, optionally selecting a single job
145 $ gh run view
146
147 # View a specific run
148 $ gh run view 12345
149
150 # View a specific run with specific attempt number
151 $ gh run view 12345 --attempt 3
152
153 # View a specific job within a run
154 $ gh run view --job 456789
155
156 # View the full log for a specific job
157 $ gh run view --log --job 456789
158
159 # Exit non-zero if a run failed
160 $ gh run view 0451 --exit-status && echo "run pending or passed"
161 `),
162 RunE: func(cmd *cobra.Command, args []string) error {
163 // support `-R, --repo` override
164 opts.BaseRepo = f.BaseRepo
165

Callers 1

TestNewCmdViewFunction · 0.70

Calls 8

FlagErrorfFunction · 0.92
AddJSONFlagsFunction · 0.92
CanPromptMethod · 0.80
ColorSchemeMethod · 0.80
WarningIconMethod · 0.80
runViewFunction · 0.70
ConfigMethod · 0.65
CacheDirMethod · 0.65

Tested by 1

TestNewCmdViewFunction · 0.56