mirror of
https://github.com/sosedoff/pgweb.git
synced 2024-12-14 19:21:46 +03:00
Add --pass flat to specify user password, closes #18, via @waltonseymour
This commit is contained in:
parent
ee4883b448
commit
01666c8f3d
@ -74,6 +74,7 @@ Application Options:
|
||||
--host= Server hostname or IP (localhost)
|
||||
--port= Server port (5432)
|
||||
--user= Database user (postgres)
|
||||
--pass= Password for user
|
||||
--db= Database name (postgres)
|
||||
--ssl= SSL option (disable)
|
||||
--listen= HTTP server listen port (8080)
|
||||
|
9
main.go
9
main.go
@ -19,6 +19,7 @@ var options struct {
|
||||
Host string `long:"host" description:"Server hostname or IP" default:"localhost"`
|
||||
Port int `long:"port" description:"Server port" default:"5432"`
|
||||
User string `long:"user" description:"Database user" default:"postgres"`
|
||||
Pass string `long:"pass" description:"Password for user"`
|
||||
DbName string `long:"db" description:"Database name" default:"postgres"`
|
||||
Ssl string `long:"ssl" description:"SSL option" default:"disable"`
|
||||
HttpPort uint `long:"listen" description:"HTTP server listen port" default:"8080"`
|
||||
@ -36,12 +37,18 @@ func getConnectionString() string {
|
||||
return options.Url
|
||||
}
|
||||
|
||||
return fmt.Sprintf(
|
||||
str := fmt.Sprintf(
|
||||
"host=%s port=%d user=%s dbname=%s sslmode=%s",
|
||||
options.Host, options.Port,
|
||||
options.User, options.DbName,
|
||||
options.Ssl,
|
||||
)
|
||||
|
||||
if options.Pass != "" {
|
||||
str += fmt.Sprintf(" password=%s", options.Pass)
|
||||
}
|
||||
|
||||
return str
|
||||
}
|
||||
|
||||
func initClient() {
|
||||
|
Loading…
Reference in New Issue
Block a user