refactor: function rename
`errorExit` renamed to `showSubcommandHelpAndError`
This commit is contained in:
parent
8267d4202b
commit
ffd1b3a771
@ -55,7 +55,7 @@ on your $PATH.
|
|||||||
Action: func(c *cli.Context) error {
|
Action: func(c *cli.Context) error {
|
||||||
appType := c.Args().First()
|
appType := c.Args().First()
|
||||||
if appType == "" {
|
if appType == "" {
|
||||||
errorExit(c, "new", errors.New("no app type provided"))
|
showSubcommandHelpAndError(c, errors.New("no app type provided"))
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,11 +7,9 @@ import (
|
|||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
// errorExit exits the program on error, logs the error to the terminal, and shows the help command.
|
// showSubcommandHelpAndError 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
|
func showSubcommandHelpAndError(c *cli.Context, err interface{}) {
|
||||||
// Example: "" for `app new` gets the app help, "new" gets the `new` subcommand help
|
cli.ShowSubcommandHelp(c)
|
||||||
func errorExit(c *cli.Context, command string, err interface{}) {
|
|
||||||
cli.ShowCommandHelp(c, command)
|
|
||||||
logrus.Error(err)
|
logrus.Error(err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user