Exemple #1
0
// Returns an exit code for main's deferred os.Exit. Tries to assist the user to
// work around certain types of errors.
func runCommand(cmd *cli.Cmd) int {
	// Run the command and handle the error.
	err := cmd.RunCli()
	switch {
	case err == nil:
		// Successful run.
		return 0
	// case err == utils.CommandAbortedErr:
	// 	// Command aborted by user without error.
	// 	fmt.Fprintln(os.Stdout, "Command aborted by user.\n")
	// 	return 1
	case err == cli.PanicError:
		// Handle panics from commands.
		reportPanic()
		return 1
	}

	return handleTypedErrors(cmd, err)
}