(cli *cli)
| 101 | } |
| 102 | |
| 103 | func buildRootCmd(cli *cli) *cobra.Command { |
| 104 | rootCmd := &cobra.Command{ |
| 105 | Use: "auth0", |
| 106 | SilenceUsage: true, |
| 107 | SilenceErrors: true, |
| 108 | Short: rootShort, |
| 109 | Long: rootShort + "\n" + getLogin(cli), |
| 110 | Version: buildinfo.GetVersionWithCommit(), |
| 111 | PersistentPreRunE: func(cmd *cobra.Command, args []string) error { |
| 112 | cli.executedCommandPath = cmd.CommandPath() |
| 113 | |
| 114 | ansi.Initialize(cli.noColor) |
| 115 | prepareInteractivity(cmd) |
| 116 | cli.configureRenderer() |
| 117 | |
| 118 | if !commandRequiresAuthentication(cmd.CommandPath()) { |
| 119 | return nil |
| 120 | } |
| 121 | |
| 122 | if err := cli.setupWithAuthentication(cmd.Context()); err != nil { |
| 123 | return err |
| 124 | } |
| 125 | |
| 126 | return nil |
| 127 | }, |
| 128 | } |
| 129 | |
| 130 | return rootCmd |
| 131 | } |
| 132 | |
| 133 | func commandRequiresAuthentication(invokedCommandName string) bool { |
| 134 | commandsWithNoAuthRequired := []string{ |
no test coverage detected