Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
289 changes: 0 additions & 289 deletions Gopkg.lock

This file was deleted.

62 changes: 0 additions & 62 deletions Gopkg.toml

This file was deleted.

1 change: 1 addition & 0 deletions README.md
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ Flags:
-w, --password string Password for the user to connect to database
-p, --port int Port number of the postgres database
-r, --rows int Total rows to be faked or mocked (default 10)
--uri string Postgres connection URI, eg. postgres://user:pass@host:=port/db?sslmode=disable
-u, --username string Username to connect to the database
-v, --verbose Enable verbose or debug logging
--version version for mock
Expand Down
13 changes: 13 additions & 0 deletions cmd.go
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ type Command struct {
DontPrompt bool
SchemaName string
File string
Uri string
}

// Database command line options
Expand Down Expand Up @@ -62,6 +63,16 @@ var rootCmd = &cobra.Command{
Fatalf("Argument Error: minimum row cannot be less than 1")
}

// There can only be one option either uri or database connection values
isDatabaseArgumentsSet := !IsStringEmpty(cmdOptions.Database) ||
!IsStringEmpty(cmdOptions.Hostname) || !IsStringEmpty(cmdOptions.Username) ||
!IsStringEmpty(cmdOptions.Password) || cmdOptions.Port > 0

if !IsStringEmpty(cmdOptions.Uri) && isDatabaseArgumentsSet {
Warnf("Database Uri are given preference for database connection, when used along with database " +
"connection arguments, using URI to connect to database")
}

// Ensure we can make a successful connection to the database
// by printing the version of the database we are going to mock
dbVersion()
Expand Down Expand Up @@ -209,6 +220,8 @@ func init() {
10, "Total rows to be faked or mocked")
rootCmd.PersistentFlags().IntVarP(&cmdOptions.Port, "port", "p",
viper.GetInt("PGPORT"), "Port number of the postgres database")
rootCmd.PersistentFlags().StringVar(&cmdOptions.Uri, "uri",
"", "Postgres connection URI, eg. postgres://user:pass@host:=port/db?sslmode=disable")
rootCmd.PersistentFlags().StringVarP(&cmdOptions.Hostname, "address", "a",
viper.GetString("PGHOSTADDR"), "Hostname where the postgres database lives")
rootCmd.PersistentFlags().StringVarP(&cmdOptions.Username, "username", "u",
Expand Down
Loading