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

Function NewCmdView

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

Source from the content-addressed store, hash-verified

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

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