Execute adds all child commands to the root command sets flags appropriately. This is called by main.main(). It only needs to happen once to the rootCmd.
()
| 303 | // Execute adds all child commands to the root command sets flags appropriately. |
| 304 | // This is called by main.main(). It only needs to happen once to the rootCmd. |
| 305 | func Execute() { |
| 306 | args := os.Args[1:] |
| 307 | jsonErrorOutput := outputJSONRequested(args) |
| 308 | if err := rawArgsHelpOutputFormatError(args); err != nil { |
| 309 | renderCommandErrorWithJSON(RootCmd, err, jsonErrorOutput) |
| 310 | os.Exit(exitCodeForError(err)) |
| 311 | } |
| 312 | |
| 313 | restoreDeprecatedCommands := func() {} |
| 314 | if rawArgsRequestJSONHelp(args) { |
| 315 | restoreDeprecatedCommands = temporarilyClearDeprecatedCommands(RootCmd) |
| 316 | } |
| 317 | defer restoreDeprecatedCommands() |
| 318 | defer finishCommandContext() |
| 319 | |
| 320 | cmd, err := RootCmd.ExecuteC() |
| 321 | if err != nil { |
| 322 | renderCommandErrorWithJSON(cmd, err, jsonErrorOutput) |
| 323 | os.Exit(exitCodeForError(err)) |
| 324 | } |
| 325 | } |
| 326 | |
| 327 | func loadOAuthCredentialsFromEnv() { |
| 328 | personalAppKey = getEnv("DROPBOX_PERSONAL_APP_KEY", personalAppKey) |