printTargets renders page metadata with the configured printer. When listing, every shortcut is printed; otherwise only the requested shortcut is printed.
(opts *OpenOptions, listing bool)
| 240 | // printTargets renders page metadata with the configured printer. When listing, |
| 241 | // every shortcut is printed; otherwise only the requested shortcut is printed. |
| 242 | func printTargets(opts *OpenOptions, listing bool) error { |
| 243 | printer, err := opts.PrintFlags.ToPrinter() |
| 244 | if err != nil { |
| 245 | return err |
| 246 | } |
| 247 | |
| 248 | if listing { |
| 249 | return printer.Print(opts.IO, opts.allEntries()) |
| 250 | } |
| 251 | |
| 252 | baseURL, appID, displayAppID := opts.resolveScope() |
| 253 | entry, ok := entryFor(opts.Shortcut, baseURL, appID, displayAppID) |
| 254 | if !ok { |
| 255 | return unsupportedShortcutError(opts.Shortcut) |
| 256 | } |
| 257 | |
| 258 | return printer.Print(opts.IO, entry) |
| 259 | } |
| 260 | |
| 261 | // resolveScope returns the dashboard base URL and the application id used to |
| 262 | // build dashboard links. displayAppID falls back to a placeholder so links can |
no test coverage detected