(cli *cli, inputs *promptsTextInput)
| 113 | } |
| 114 | |
| 115 | func showPromptsText(cli *cli, inputs *promptsTextInput) func(cmd *cobra.Command, args []string) error { |
| 116 | return func(cmd *cobra.Command, args []string) error { |
| 117 | if len(args) == 0 { |
| 118 | if err := customTextPrompt.Pick(cmd, &inputs.Prompt, customTextPromptOptions); err != nil { |
| 119 | return err |
| 120 | } |
| 121 | } else { |
| 122 | inputs.Prompt = args[0] |
| 123 | } |
| 124 | |
| 125 | brandingText := make(map[string]interface{}) |
| 126 | if err := ansi.Waiting(func() (err error) { |
| 127 | brandingText, err = cli.api.Prompt.CustomText(cmd.Context(), inputs.Prompt, inputs.Language) |
| 128 | return err |
| 129 | }); err != nil { |
| 130 | return fmt.Errorf( |
| 131 | "failed to fetch custom text for prompt %q and language %q: %w", |
| 132 | inputs.Prompt, |
| 133 | inputs.Language, |
| 134 | err, |
| 135 | ) |
| 136 | } |
| 137 | |
| 138 | brandingTextJSON, err := json.MarshalIndent(brandingText, "", " ") |
| 139 | if err != nil { |
| 140 | return fmt.Errorf("failed to serialize the prompt custom text to JSON: %w", err) |
| 141 | } |
| 142 | |
| 143 | cli.renderer.BrandingTextShow(string(brandingTextJSON), inputs.Prompt, inputs.Language) |
| 144 | |
| 145 | return nil |
| 146 | } |
| 147 | } |
| 148 | |
| 149 | func updateBrandingText(cli *cli, inputs *promptsTextInput) func(cmd *cobra.Command, args []string) error { |
| 150 | return func(cmd *cobra.Command, args []string) error { |
no test coverage detected