(ctx context.Context, flags *RootFlags)
| 286 | } |
| 287 | |
| 288 | func (c *SearchConsoleSitemapsGetCmd) Run(ctx context.Context, flags *RootFlags) error { |
| 289 | u := ui.FromContext(ctx) |
| 290 | siteURL := strings.TrimSpace(c.SiteURL) |
| 291 | if siteURL == "" { |
| 292 | return usage("empty siteUrl") |
| 293 | } |
| 294 | feedPath := strings.TrimSpace(c.FeedPath) |
| 295 | if feedPath == "" { |
| 296 | return usage("empty feedpath") |
| 297 | } |
| 298 | |
| 299 | account, err := requireAccount(flags) |
| 300 | if err != nil { |
| 301 | return err |
| 302 | } |
| 303 | |
| 304 | svc, err := searchConsoleService(ctx, account) |
| 305 | if err != nil { |
| 306 | return err |
| 307 | } |
| 308 | sitemap, err := svc.Sitemaps.Get(siteURL, feedPath).Context(ctx).Do() |
| 309 | if err != nil { |
| 310 | return wrapSearchConsoleError(err) |
| 311 | } |
| 312 | |
| 313 | if outfmt.IsJSON(ctx) { |
| 314 | return outfmt.WriteJSON(ctx, stdoutWriter(ctx), map[string]any{ |
| 315 | "sitemap": sitemap, |
| 316 | }) |
| 317 | } |
| 318 | |
| 319 | return writeResult(ctx, u, |
| 320 | kv("path", sitemap.Path), |
| 321 | kv("type", sitemap.Type), |
| 322 | kv("pending", sitemap.IsPending), |
| 323 | kv("warnings", sitemap.Warnings), |
| 324 | kv("errors", sitemap.Errors), |
| 325 | kv("last_submitted", sitemap.LastSubmitted), |
| 326 | kv("last_downloaded", sitemap.LastDownloaded), |
| 327 | kv("contents", formatSearchConsoleSitemapContents(sitemap.Contents)), |
| 328 | ) |
| 329 | } |
| 330 | |
| 331 | type SearchConsoleSitemapsSubmitCmd struct { |
| 332 | SiteURL string `arg:"" name:"siteUrl" help:"Search Console property URL (e.g. https://example.com/ or sc-domain:example.com)"` |
nothing calls this directly
no test coverage detected