(options Options, start, end int64, tabID string)
| 155 | } |
| 156 | |
| 157 | func buildTextStyleRequest(options Options, start, end int64, tabID string) (*docs.Request, bool, error) { |
| 158 | style := &docs.TextStyle{} |
| 159 | var fields []string |
| 160 | |
| 161 | if options.Code { |
| 162 | if strings.TrimSpace(options.FontFamily) != "" { |
| 163 | return nil, false, ValidationError("--code cannot be combined with --font-family") |
| 164 | } |
| 165 | |
| 166 | if strings.TrimSpace(options.Background) != "" { |
| 167 | return nil, false, ValidationError("--code cannot be combined with --bg-color") |
| 168 | } |
| 169 | style.WeightedFontFamily = &docs.WeightedFontFamily{FontFamily: "Courier New"} |
| 170 | style.BackgroundColor = greyColor(codeBackgroundGrey) |
| 171 | |
| 172 | fields = append(fields, "weightedFontFamily", "backgroundColor") |
| 173 | } |
| 174 | |
| 175 | if font := strings.TrimSpace(options.FontFamily); font != "" { |
| 176 | style.WeightedFontFamily = &docs.WeightedFontFamily{FontFamily: font} |
| 177 | |
| 178 | fields = append(fields, "weightedFontFamily") |
| 179 | } |
| 180 | |
| 181 | if options.FontSize < 0 { |
| 182 | return nil, false, ValidationError("--font-size must be positive") |
| 183 | } |
| 184 | |
| 185 | if options.FontSize > 0 { |
| 186 | style.FontSize = &docs.Dimension{Magnitude: options.FontSize, Unit: "PT"} |
| 187 | |
| 188 | fields = append(fields, "fontSize") |
| 189 | } |
| 190 | |
| 191 | if color := strings.TrimSpace(options.TextColor); color != "" { |
| 192 | optionalColor, err := Color(color, "--text-color") |
| 193 | if err != nil { |
| 194 | return nil, false, err |
| 195 | } |
| 196 | style.ForegroundColor = optionalColor |
| 197 | |
| 198 | fields = append(fields, "foregroundColor") |
| 199 | } |
| 200 | |
| 201 | if color := strings.TrimSpace(options.Background); color != "" { |
| 202 | optionalColor, err := Color(color, "--bg-color") |
| 203 | if err != nil { |
| 204 | return nil, false, err |
| 205 | } |
| 206 | style.BackgroundColor = optionalColor |
| 207 | |
| 208 | fields = append(fields, "backgroundColor") |
| 209 | } |
| 210 | |
| 211 | if strings.TrimSpace(options.Link) != "" && options.ClearLink { |
| 212 | return nil, false, ValidationError("--link and --no-link cannot be combined") |
| 213 | } |
| 214 |
no test coverage detected