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

Function NewCmdView

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

Source from the content-addressed store, hash-verified

101}
102
103func NewCmdView(f *cmdutil.Factory, runF func(*ViewOptions) error) *cobra.Command {
104 opts := &ViewOptions{
105 IO: f.IOStreams,
106 HttpClient: f.HttpClient,
107 Prompter: f.Prompter,
108 Now: time.Now,
109 Browser: f.Browser,
110 }
111
112 cmd := &cobra.Command{
113 Use: "view [<run-id>]",
114 Short: "View a summary of a workflow run",
115 Long: heredoc.Docf(`
116 View a summary of a workflow run.
117
118 Due to platform limitations, %[1]sgh%[1]s may not always be able to associate jobs with their
119 corresponding logs when using the primary method of fetching logs in zip format.
120
121 In such cases, %[1]sgh%[1]s will attempt to fetch logs for each job individually via the API.
122 This fallback is slower and more resource-intensive. If more than 25 job logs are missing,
123 the operation will fail with an error.
124
125 Additionally, due to similar platform constraints, some log lines may not be
126 associated with a specific step within a job. In these cases, the step name will
127 appear as %[1]sUNKNOWN STEP%[1]s in the log output.
128 `, "`", maxAPILogFetchers),
129 Args: cobra.MaximumNArgs(1),
130 Example: heredoc.Doc(`
131 # Interactively select a run to view, optionally selecting a single job
132 $ gh run view
133
134 # View a specific run
135 $ gh run view 12345
136
137 # View a specific run with specific attempt number
138 $ gh run view 12345 --attempt 3
139
140 # View a specific job within a run
141 $ gh run view --job 456789
142
143 # View the full log for a specific job
144 $ gh run view --log --job 456789
145
146 # Exit non-zero if a run failed
147 $ gh run view 0451 --exit-status && echo "run pending or passed"
148 `),
149 RunE: func(cmd *cobra.Command, args []string) error {
150 // support `-R, --repo` override
151 opts.BaseRepo = f.BaseRepo
152
153 config, err := f.Config()
154 if err != nil {
155 return err
156 }
157
158 opts.RunLogCache = RunLogCache{
159 cacheDir: config.CacheDir(),
160 }

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