From bb26c6d3a4f96a8e87cf14bb72ef283c86e8891a Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sat, 29 Apr 2017 19:02:02 +0200 Subject: PostgresClient: Basic implementation of #build_command Correctly builds the required arguments. Doesn't handle passwords at all. --- lib/dbshell/postgres_client.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/dbshell/postgres_client.rb b/lib/dbshell/postgres_client.rb index a22ccf7..b77e681 100644 --- a/lib/dbshell/postgres_client.rb +++ b/lib/dbshell/postgres_client.rb @@ -1,4 +1,18 @@ class DBShell::PostgresClient + EXECUTABLE_NAME = 'psql' + def self.build_command(db_info) + args = [EXECUTABLE_NAME] + + host = db_info['host'] + port = db_info['port'] + db_name = db_info['database'] + user = db_info['username'] + password = db_info['password'] + + args.push('-U', user) if user + args.push('-h', host) if host + args.push('-p', port) if port + args.push(db_name) end end -- cgit v1.2.3