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

Function aculConfigGenerateCmd

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

Source from the content-addressed store, hash-verified

209}
210
211func aculConfigGenerateCmd(cli *cli) *cobra.Command {
212 var input aculConfigInput
213
214 cmd := &cobra.Command{
215 Use: "generate",
216 Args: cobra.MaximumNArgs(1),
217 Short: "Generate a stub config file for a Universal Login screen.",
218 Long: "Generate a stub config file for a Universal Login screen and save it to a file.\n" +
219 "If fileName is not provided, it will default to <screen-name>.json in the current directory.",
220 Example: ` auth0 acul config generate <screen-name>
221 auth0 acul config generate <screen-name> --file settings.json
222 auth0 acul config generate signup-id
223 auth0 acul config generate login-id --file login-settings.json`,
224 RunE: func(cmd *cobra.Command, args []string) error {
225 if err := ensureACULPrerequisites(cmd.Context(), cli.api); err != nil {
226 return err
227 }
228
229 screens, err := validateAndSelectScreens(cli, utils.FetchKeys(ScreenPromptMap), args, false)
230 if err != nil {
231 return err
232 }
233
234 input.screenName = screens[0]
235
236 if err := ensureConfigFilePath(&input, cli); err != nil {
237 return err
238 }
239
240 config := defaultACULConfig()
241
242 // Error handling omitted for brevity.
243 data, _ := json.MarshalIndent(config, "", " ")
244
245 message := fmt.Sprintf("Overwrite file '%s' with default config? : ", ansi.Green(input.filePath))
246 if shouldCancelOverwrite(cli, cmd, input.filePath, message) {
247 return nil
248 }
249
250 if err := os.WriteFile(input.filePath, data, 0644); err != nil {
251 return fmt.Errorf("could not write config: %w", err)
252 }
253
254 cli.renderer.Infof("Configuration generated at '%s'", ansi.Green(input.filePath))
255
256 cli.renderer.Output("Learn more about configuring ACUL screens https://auth0.com/docs/customize/login-pages/advanced-customizations/getting-started/configure-acul-screens")
257
258 cli.renderer.Output(ansi.Yellow("💡 Tip: Use `auth0 acul config get` to fetch remote rendering settings or `auth0 acul config set` to sync local configs."))
259 return nil
260 },
261 }
262
263 file.RegisterString(cmd, &input.filePath, "")
264 return cmd
265}
266
267func aculConfigGetCmd(cli *cli) *cobra.Command {
268 var input aculConfigInput

Callers 1

aculConfigureCmdFunction · 0.85

Calls 12

FetchKeysFunction · 0.92
GreenFunction · 0.92
YellowFunction · 0.92
ensureACULPrerequisitesFunction · 0.85
validateAndSelectScreensFunction · 0.85
ensureConfigFilePathFunction · 0.85
defaultACULConfigFunction · 0.85
shouldCancelOverwriteFunction · 0.85
ErrorfMethod · 0.80
InfofMethod · 0.80
OutputMethod · 0.80
RegisterStringMethod · 0.80

Tested by

no test coverage detected