(ctx context.Context, flags *RootFlags)
| 334 | } |
| 335 | |
| 336 | func (c *SearchConsoleSitemapsSubmitCmd) Run(ctx context.Context, flags *RootFlags) error { |
| 337 | u := ui.FromContext(ctx) |
| 338 | siteURL := strings.TrimSpace(c.SiteURL) |
| 339 | if siteURL == "" { |
| 340 | return usage("empty siteUrl") |
| 341 | } |
| 342 | feedPath := strings.TrimSpace(c.FeedPath) |
| 343 | if feedPath == "" { |
| 344 | return usage("empty feedpath") |
| 345 | } |
| 346 | if err := validateSearchConsoleSitemapURL(feedPath); err != nil { |
| 347 | return err |
| 348 | } |
| 349 | |
| 350 | if err := dryRunExit(ctx, flags, "searchconsole.sitemaps.submit", map[string]any{ |
| 351 | "site_url": siteURL, |
| 352 | "feed_path": feedPath, |
| 353 | }); err != nil { |
| 354 | return err |
| 355 | } |
| 356 | |
| 357 | account, err := requireAccount(flags) |
| 358 | if err != nil { |
| 359 | return err |
| 360 | } |
| 361 | |
| 362 | svc, err := searchConsoleService(ctx, account) |
| 363 | if err != nil { |
| 364 | return err |
| 365 | } |
| 366 | if err := svc.Sitemaps.Submit(siteURL, feedPath).Context(ctx).Do(); err != nil { |
| 367 | return wrapSearchConsoleError(err) |
| 368 | } |
| 369 | |
| 370 | return writeResult(ctx, u, |
| 371 | kv("submitted", true), |
| 372 | kv("site_url", siteURL), |
| 373 | kv("feed_path", feedPath), |
| 374 | ) |
| 375 | } |
| 376 | |
| 377 | type SearchConsoleSitemapsDeleteCmd struct { |
| 378 | 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