(ctx context.Context, cli *cli, inputs *promptsTextInput)
| 190 | } |
| 191 | |
| 192 | func fetchBrandingTextContentToEdit(ctx context.Context, cli *cli, inputs *promptsTextInput) (string, error) { |
| 193 | contentToEdit := map[string]interface{}{textDocsKey: textDocsURL} |
| 194 | |
| 195 | if err := ansi.Waiting(func() error { |
| 196 | defaultTranslations := downloadDefaultBrandingTextTranslations(inputs.Prompt, inputs.Language) |
| 197 | |
| 198 | customTranslations, err := cli.api.Prompt.CustomText(ctx, inputs.Prompt, inputs.Language) |
| 199 | if err != nil { |
| 200 | return err |
| 201 | } |
| 202 | |
| 203 | brandingTextTranslations := mergeBrandingTextTranslations(defaultTranslations, customTranslations) |
| 204 | |
| 205 | for key, text := range brandingTextTranslations { |
| 206 | contentToEdit[key] = text |
| 207 | } |
| 208 | |
| 209 | return nil |
| 210 | }); err != nil { |
| 211 | return "", fmt.Errorf( |
| 212 | "failed to load custom text for prompt %q and language %q: %w", |
| 213 | inputs.Prompt, |
| 214 | inputs.Language, |
| 215 | err, |
| 216 | ) |
| 217 | } |
| 218 | |
| 219 | contentToEditJSON, err := json.MarshalIndent(contentToEdit, "", " ") |
| 220 | if err != nil { |
| 221 | return "", fmt.Errorf("failed to serialize the prompt custom text to JSON: %w", err) |
| 222 | } |
| 223 | |
| 224 | return string(contentToEditJSON), nil |
| 225 | } |
| 226 | |
| 227 | // downloadDefaultBrandingTextTranslations will download all the prompt's possible |
| 228 | // screen values. In case of encountering any errors it will simply ignore them |
no test coverage detected