moby/cli/flagerrors.go
Vincent Demeester 1bcc2d9ab7 Fixing Regression in exit codes in 1.12
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
2016-09-21 20:43:02 +02:00

24 lines
470 B
Go

package cli
import (
"fmt"
"github.com/spf13/cobra"
)
// FlagErrorFunc prints an error messages which matches the format of the
// docker/docker/cli error messages
func FlagErrorFunc(cmd *cobra.Command, err error) error {
if err == nil {
return err
}
usage := ""
if cmd.HasSubCommands() {
usage = "\n\n" + cmd.UsageString()
}
return StatusError{
Status: fmt.Sprintf("%s\nSee '%s --help'.%s", err, cmd.CommandPath(), usage),
StatusCode: 125,
}
}