| 122 | } |
| 123 | |
| 124 | func chkRunError(err error) error { |
| 125 | type argNamer interface { |
| 126 | ArgName() string |
| 127 | } |
| 128 | if perfops.IsUnauthorized(err) { |
| 129 | // A bit of a hack... |
| 130 | err = errors.New("The API token was declined. Please correct it or do not send a token to use the free plan.") |
| 131 | } else if namer, ok := err.(argNamer); ok { |
| 132 | rootCmd.SetHelpFunc(invalidArgHelp(namer.ArgName())) |
| 133 | err = flag.ErrHelp |
| 134 | } |
| 135 | return err |
| 136 | } |
| 137 | |
| 138 | func invalidArgHelp(name string) func(cmd *cobra.Command, args []string) { |
| 139 | if name == "limit" { |