MCPcopy Create free account
hub / github.com/auth0/auth0-cli / fetchBrandingTextContentToEdit

Function fetchBrandingTextContentToEdit

internal/cli/prompts_custom_text.go:192–225  ·  view source on GitHub ↗
(ctx context.Context, cli *cli, inputs *promptsTextInput)

Source from the content-addressed store, hash-verified

190}
191
192func 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

Callers 1

updateBrandingTextFunction · 0.85

Calls 5

WaitingFunction · 0.92
ErrorfMethod · 0.80
CustomTextMethod · 0.65

Tested by

no test coverage detected