use jiracli.Error object to disambiguate between kingpin errors and cli errors

This commit is contained in:
Cory Bennett
2017-09-01 23:30:59 -07:00
parent fce78dea68
commit fb1bfeb8f5
2 changed files with 23 additions and 5 deletions
+10 -5
View File
@@ -329,11 +329,16 @@ func main() {
} }
} }
if _, err := app.Parse(os.Args[1:]); err != nil { if _, err := app.Parse(os.Args[1:]); err != nil {
ctx, _ := app.ParseContext(os.Args[1:]) if _, ok := err.(*jiracli.Error); ok {
if ctx != nil { log.Errorf("%s", err)
app.UsageForContext(ctx) panic(jiracli.Exit{Code: 1})
} else {
ctx, _ := app.ParseContext(os.Args[1:])
if ctx != nil {
app.UsageForContext(ctx)
}
log.Errorf("Invalid Usage: %s", err)
panic(jiracli.Exit{Code: 1})
} }
log.Errorf("Invalid Usage: %s", err)
panic(jiracli.Exit{Code: 1})
} }
} }
+13
View File
@@ -0,0 +1,13 @@
package jiracli
import "github.com/pkg/errors"
type Error struct {
error
}
func cliError(cause error) error {
return &Error{
errors.WithStack(cause),
}
}