From b80c7640295bb7db57e91461d2aae4d8377f20a6 Mon Sep 17 00:00:00 2001 From: Ben Burwell Date: Wed, 3 Jun 2020 00:15:46 -0400 Subject: Specify the database connection in CLI args --- Makefile | 2 +- main.go | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index e12d79d..53e0529 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ $(BINARY): $(SOURCES) .PHONY: run run: $(BINARY) - ./$(BINARY) 2>>/tmp/pgqt.log + ./$(BINARY) postgres://postgres:password@localhost/postgres?sslmode=disable 2>>/tmp/pgqt.log .PHONY: clean clean: diff --git a/main.go b/main.go index 5639ea4..9088cd4 100644 --- a/main.go +++ b/main.go @@ -1,6 +1,7 @@ package main import ( + "fmt" "log" "os" @@ -13,7 +14,11 @@ import ( var app = tview.NewApplication() func main() { - db, err := postgres.Open("postgres://postgres:password@localhost:5432/postgres?sslmode=disable") + if len(os.Args) < 2 { + fmt.Fprintf(os.Stderr, "usage: %s \n", os.Args[0]) + os.Exit(1) + } + db, err := postgres.Open(os.Args[1]) if err != nil { log.Printf("could not connect to db: %v", err) os.Exit(1) -- cgit v1.2.3