(ctx context.Context, flags *RootFlags)
| 77 | ) |
| 78 | |
| 79 | func (c *DocsFormatCmd) Run(ctx context.Context, flags *RootFlags) error { |
| 80 | id := strings.TrimSpace(c.DocID) |
| 81 | if id == "" { |
| 82 | return usage("empty docId") |
| 83 | } |
| 84 | format := c.Format.withLinkFlags(c.Link, c.NoLink) |
| 85 | if !format.any() { |
| 86 | return usage("no formatting flags provided") |
| 87 | } |
| 88 | if c.MatchAll && strings.TrimSpace(c.Match) == "" { |
| 89 | return usage("--match-all requires --match") |
| 90 | } |
| 91 | |
| 92 | tab, tabErr := resolveTabArg(ctx, c.Tab, c.TabID) |
| 93 | if tabErr != nil { |
| 94 | return tabErr |
| 95 | } |
| 96 | c.Tab = tab |
| 97 | if _, err := format.buildRequests(1, 2, c.Tab); err != nil { |
| 98 | return err |
| 99 | } |
| 100 | |
| 101 | if err := dryRunExit(ctx, flags, "docs.format", map[string]any{ |
| 102 | "document_id": id, |
| 103 | "match": c.Match, |
| 104 | "match_all": c.MatchAll, |
| 105 | "match_case": c.MatchCase, |
| 106 | "tab": c.Tab, |
| 107 | "segment": c.Segment, |
| 108 | "batch": c.Batch, |
| 109 | "format": map[string]any{ |
| 110 | "font_family": c.Format.FontFamily, |
| 111 | "font_size": c.Format.FontSize, |
| 112 | "text_color": c.Format.TextColor, |
| 113 | "bg_color": c.Format.BgColor, |
| 114 | "link": c.Link, |
| 115 | "no_link": c.NoLink, |
| 116 | "code": c.Format.Code, |
| 117 | "bold": c.Format.Bold, |
| 118 | "no_bold": c.Format.NoBold, |
| 119 | "italic": c.Format.Italic, |
| 120 | "no_italic": c.Format.NoItalic, |
| 121 | "underline": c.Format.Underline, |
| 122 | "no_underline": c.Format.NoUnderline, |
| 123 | "strikethrough": c.Format.Strikethrough, |
| 124 | "no_strike": c.Format.NoStrike, |
| 125 | "alignment": c.Format.Alignment, |
| 126 | "line_spacing": c.Format.LineSpacing, |
| 127 | "spacing_mode": c.Format.SpacingMode, |
| 128 | "heading_level": c.Format.HeadingLevel, |
| 129 | "named_style": c.Format.NamedStyle, |
| 130 | "bullets": c.Format.Bullets, |
| 131 | "ordered": c.Format.Ordered, |
| 132 | "bullet_preset": c.Format.BulletPreset, |
| 133 | "no_bullets": c.Format.NoBullets, |
| 134 | "indent_start": c.Format.IndentStart, |
| 135 | "indent_first_line": c.Format.IndentFirstLine, |
| 136 | "indent_end": c.Format.IndentEnd, |
nothing calls this directly
no test coverage detected