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

Function collectName

internal/cli/quickstarts.go:786–820  ·  view source on GitHub ↗

collectName prompts for the application/API name if not already provided.

(cmd *cobra.Command, inputs *SetupInputs)

Source from the content-addressed store, hash-verified

784
785// collectName prompts for the application/API name if not already provided.
786func collectName(cmd *cobra.Command, inputs *SetupInputs) error {
787 if setupName.IsSet(cmd) {
788 if inputs.Name == "" {
789 return fmt.Errorf("application name cannot be empty")
790 }
791 return nil
792 }
793
794 switch {
795 case inputs.App:
796 defaultName := inputs.Name
797 if defaultName == "" {
798 defaultName = "My App"
799 }
800 inputs.Name = defaultName
801 if err := setupName.Ask(cmd, &inputs.Name, &defaultName); err != nil {
802 return fmt.Errorf("failed to enter application name: %w", err)
803 }
804 if inputs.Name == "" {
805 return fmt.Errorf("application name cannot be empty")
806 }
807
808 case inputs.API && inputs.Name == "":
809 cwd, _ := os.Getwd()
810 defaultName := filepath.Base(cwd)
811 if defaultName == "" || defaultName == "." {
812 defaultName = "my-api"
813 }
814 inputs.Name = defaultName
815 if err := setupName.Ask(cmd, &inputs.Name, &defaultName); err != nil {
816 return fmt.Errorf("failed to enter API name: %w", err)
817 }
818 }
819 return nil
820}
821
822func collectAPIInputs(cmd *cobra.Command, cli *cli, inputs *SetupInputs) error {
823 // Identifier.

Callers 1

runSetupQuickstartFunction · 0.85

Calls 3

IsSetMethod · 0.80
ErrorfMethod · 0.80
AskMethod · 0.45

Tested by

no test coverage detected