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

Function aculConfigGetCmd

internal/cli/acul_config.go:267–330  ·  view source on GitHub ↗
(cli *cli)

Source from the content-addressed store, hash-verified

265}
266
267func aculConfigGetCmd(cli *cli) *cobra.Command {
268 var input aculConfigInput
269
270 cmd := &cobra.Command{
271 Use: "get",
272 Args: cobra.MaximumNArgs(1),
273 Short: "Get the current rendering settings for a specific screen",
274 Long: "Get the current rendering settings for a specific screen.",
275 Example: ` auth0 acul config get <screen-name>
276 auth0 acul config get <screen-name> --file settings.json
277 auth0 acul config get signup-id
278 auth0 acul config get login-id -f ./acul_config/login-id.json`,
279 RunE: func(cmd *cobra.Command, args []string) error {
280 ctx := cmd.Context()
281 if err := ensureACULPrerequisites(cmd.Context(), cli.api); err != nil {
282 return err
283 }
284
285 screens, err := validateAndSelectScreens(cli, utils.FetchKeys(ScreenPromptMap), args, false)
286 if err != nil {
287 return err
288 }
289
290 input.screenName = screens[0]
291
292 existingRenderSettings, err := cli.api.Prompt.ReadRendering(ctx, management.PromptType(ScreenPromptMap[input.screenName]), management.ScreenName(input.screenName))
293 if err != nil {
294 return fmt.Errorf("failed to fetch the existing render settings: %w", err)
295 }
296
297 if existingRenderSettings == nil {
298 cli.renderer.Warnf("No rendering settings found for screen '%s' in tenant '%s'.", ansi.Green(input.screenName), ansi.Blue(cli.tenant))
299 cli.renderer.Output(ansi.Yellow("💡 Tip: Use `auth0 acul config generate` to generate a stub config file or `auth0 acul config set` to sync local configs."))
300 cli.renderer.Output(ansi.Cyan("📖 Customization Guide: https://github.com/auth0/auth0-cli/blob/main/CUSTOMIZATION_GUIDE.md"))
301 return nil
302 }
303
304 if err := ensureConfigFilePath(&input, cli); err != nil {
305 return err
306 }
307
308 message := fmt.Sprintf("Overwrite file '%s' with new data from tenant '%s'? : ", ansi.Green(input.filePath), ansi.Blue(cli.tenant))
309 if shouldCancelOverwrite(cli, cmd, input.filePath, message) {
310 return nil
311 }
312
313 data, err := json.MarshalIndent(existingRenderSettings, "", " ")
314 if err != nil {
315 return fmt.Errorf("failed to marshal render settings: %w", err)
316 }
317 if err := os.WriteFile(input.filePath, data, 0644); err != nil {
318 return fmt.Errorf("failed to write render settings to file %q: %w", input.filePath, err)
319 }
320
321 cli.renderer.Infof("Configuration downloaded and saved at '%s'.", ansi.Green(input.filePath))
322 cli.renderer.Output(ansi.Yellow("💡 Tip: Use `auth0 acul config set` to sync local config to remote or `auth0 acul config list` to view all ACUL screens."))
323 return nil
324 },

Callers 1

aculConfigureCmdFunction · 0.85

Calls 15

FetchKeysFunction · 0.92
GreenFunction · 0.92
BlueFunction · 0.92
YellowFunction · 0.92
CyanFunction · 0.92
ensureACULPrerequisitesFunction · 0.85
validateAndSelectScreensFunction · 0.85
ensureConfigFilePathFunction · 0.85
shouldCancelOverwriteFunction · 0.85
ErrorfMethod · 0.80
WarnfMethod · 0.80
OutputMethod · 0.80

Tested by

no test coverage detected