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

Function NewCmdView

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

Source from the content-addressed store, hash-verified

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

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