From e34669b13789e64d44ca865bd5ae7ea29aef2c3a Mon Sep 17 00:00:00 2001 From: Robert Vollmert Date: Thu, 30 May 2019 19:12:42 +0200 Subject: [PATCH] More helpful usage messages for test/create_test_db --- test/create_test_db | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/test/create_test_db b/test/create_test_db index 88a6978f1..2f447e4e9 100755 --- a/test/create_test_db +++ b/test/create_test_db @@ -1,19 +1,23 @@ #! /usr/bin/env bash -if [ -z "$1" ] - then - echo "Please supply the connection uri for the user with create database privileges" - exit -1 + +usage() { + echo "$0 " + exit -1 +} + +if [ -z "$1" ]; then + echo "Please supply the connection uri for the user with create database privileges" + usage fi -if [ -z "$2" ] - then - echo "Please supply the test database name" - exit -1 +if [ -z "$2" ]; then + echo "Please supply the test database name" + usage fi -if [[ $1 != postgres://* ]] -then + +if [[ $1 != postgres://* ]]; then echo "Please use a valid connection URI (https://www.postgresql.org/docs/current/static/libpq-connect.html#AEN45347)" - exit -1 + usage fi BASEPATH=$( cd $(dirname $0) ; pwd -P )