18 lines
532 B
Go
18 lines
532 B
Go
package cli
|
|
|
|
import (
|
|
"os"
|
|
|
|
"github.com/sirupsen/logrus"
|
|
"github.com/urfave/cli/v2"
|
|
)
|
|
|
|
// errorExit exits the program on error, logs the error to the terminal, and shows the help command.
|
|
// When passing command, use an empty string to get the base command, and for a subcommand, give the name of the subcommand
|
|
// Example: "" for `app new` gets the app help, "new" gets the `new` subcommand help
|
|
func errorExit(c *cli.Context, command string, err interface{}) {
|
|
cli.ShowCommandHelp(c, command)
|
|
logrus.Error(err)
|
|
os.Exit(1)
|
|
}
|