-
-
Notifications
You must be signed in to change notification settings - Fork 582
Conversation
@@ -44,7 +44,6 @@ var RootCmd = &cobra.Command{ | |||
// This is called by main.main(). It only needs to happen once to the rootCmd. | |||
func Execute() { | |||
if err := RootCmd.Execute(); err != nil { | |||
fmt.Println(err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why did you remove the printing of the error here? or was that a mistake?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed it because it was causing the error to be printed twice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of the following
buffalo new coke --db-type SOMETHING-BAD!
Buffalo version 0.7.1
Error: Unknown db-type SOMETHING-BAD! expecting one of postgres, mysql or sqlite3
Usage:
buffalo new [name] [flags]
Flags:
--db-type string specify the type of database you want to use [postgres, mysql, sqlite3] (default "postgres")
-f, --force delete and remake if the app already exists
--skip-pop skips adding pop/soda to your app
--skip-webpack skips adding Webpack to your app
-v, --verbose verbosely print out the go get/install commands
You would get the error output again at the end. Shown below.
buffalo new coke --db-type SOMETHING-BAD!
Buffalo version 0.7.1
Error: Unknown db-type SOMETHING-BAD! expecting one of postgres, mysql or sqlite3
Usage:
buffalo new [name] [flags]
Flags:
--db-type string specify the type of database you want to use [postgres, mysql, sqlite3] (default "postgres")
-f, --force delete and remake if the app already exists
--skip-pop skips adding pop/soda to your app
--skip-webpack skips adding Webpack to your app
-v, --verbose verbosely print out the go get/install commands
Unknown db-type SOMETHING-BAD! expecting one of postgres, mysql or sqlite3
looks good. thanks! |
@markbates Thanks for the merge. I was just messing with error message situation. If setting the root command to silence errors we can add that println back and it will instead print the error at the end. I guess its a trade off on where the message gets printed really. // RootCmd is the hook for all of the other commands in the buffalo binary.
var RootCmd = &cobra.Command{
SilenceErrors: true,
Use: "buffalo",
Short: "Helps you build your Buffalo applications that much easier!",
PersistentPreRun: func(cmd *cobra.Command, args []string) {
fmt.Printf("Buffalo version %s\n\n", Version)
},
}
// Execute adds all child commands to the root command sets flags appropriately.
// This is called by main.main(). It only needs to happen once to the rootCmd.
func Execute() {
if err := RootCmd.Execute(); err != nil {
fmt.Println(fmt.Sprintf("Error: %s", err))
os.Exit(-1)
}
} That will result in the following output instead.
|
Fixes the silent failing of a unknown db-type. The following is the result.