(cli *cli)
| 265 | } |
| 266 | |
| 267 | func 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 | }, |
no test coverage detected