(options Options, start, end int64, tabID string)
| 387 | } |
| 388 | |
| 389 | func buildParagraphBulletsRequest(options Options, start, end int64, tabID string) (*docs.Request, bool, error) { |
| 390 | presetFlags := 0 |
| 391 | if options.Bullets { |
| 392 | presetFlags++ |
| 393 | } |
| 394 | |
| 395 | if options.Ordered { |
| 396 | presetFlags++ |
| 397 | } |
| 398 | |
| 399 | if strings.TrimSpace(options.BulletPreset) != "" { |
| 400 | presetFlags++ |
| 401 | } |
| 402 | |
| 403 | if presetFlags > 1 { |
| 404 | return nil, false, ValidationError("--bullets, --ordered, and --bullet-preset are mutually exclusive") |
| 405 | } |
| 406 | |
| 407 | if options.ClearBullets && presetFlags > 0 { |
| 408 | return nil, false, ValidationError("--no-bullets cannot be combined with --bullets, --ordered, or --bullet-preset") |
| 409 | } |
| 410 | |
| 411 | range_ := &docs.Range{StartIndex: start, EndIndex: end, TabId: tabID} |
| 412 | if options.ClearBullets { |
| 413 | return &docs.Request{DeleteParagraphBullets: &docs.DeleteParagraphBulletsRequest{Range: range_}}, true, nil |
| 414 | } |
| 415 | |
| 416 | if presetFlags == 0 { |
| 417 | return nil, false, nil |
| 418 | } |
| 419 | |
| 420 | preset := BulletPresetDisc |
| 421 | if options.Ordered { |
| 422 | preset = BulletPresetNumbered |
| 423 | } |
| 424 | |
| 425 | if custom := strings.ToUpper(strings.TrimSpace(options.BulletPreset)); custom != "" { |
| 426 | preset = custom |
| 427 | } |
| 428 | |
| 429 | if !validBulletPreset(preset) { |
| 430 | return nil, false, ValidationError("--bullet-preset must be a supported Google Docs bullet glyph preset") |
| 431 | } |
| 432 | |
| 433 | return &docs.Request{CreateParagraphBullets: &docs.CreateParagraphBulletsRequest{ |
| 434 | Range: range_, |
| 435 | BulletPreset: preset, |
| 436 | }}, true, nil |
| 437 | } |
| 438 | |
| 439 | func validBulletPreset(value string) bool { |
| 440 | switch value { |
no test coverage detected