Skip to content
This repository has been archived by the owner on Feb 24, 2024. It is now read-only.

fixes #183 #185

Merged
merged 3 commits into from
Jan 27, 2017
Merged

fixes #183 #185

merged 3 commits into from
Jan 27, 2017

Conversation

amedeiros
Copy link
Contributor

Fixes the silent failing of a unknown db-type. The following is the result.

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

@@ -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)
Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Contributor Author

@amedeiros amedeiros Jan 27, 2017

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

@markbates markbates merged commit 566187a into gobuffalo:master Jan 27, 2017
@markbates
Copy link
Member

looks good. thanks!

@amedeiros
Copy link
Contributor Author

@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.

buffalo new coke --db-type SOMETHING-BAD!
Buffalo version 0.7.1

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

Error: Unknown db-type SOMETHING-BAD! expecting one of postgres, mysql or sqlite3

@markbates markbates mentioned this pull request Jan 27, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants