// 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) }
func cliCreate(cmd *cli.Cmd) error { if len(cmd.Args) == 0 || len(cmd.Args) > 1 { return fmt.Errorf("Invalid command options specified.") } return cmd.Run() }
func cliList(cmd *cli.Cmd) error { if len(cmd.Args) > 0 { return fmt.Errorf("Invalid command options specified.") } return cmd.Run() }