From afbc2a590966710546196480cf6061929594be4e Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Thu, 9 Jan 2014 10:56:56 -0300 Subject: [PATCH] [PASSED QA] Bug 11509: koha-create should print better usage information This patch makes koha-create print better and more descriptive usage information. Also adds the --help and -h switches. Regards To+ Sponsored-by: Universidad Nacional de Cordoba Signed-off-by: Chris Cormack Signed-off-by: Katrin Fischer Removed trailing " from: $scriptname [db usage mode] [options] instancename" --- debian/docs/koha-create.xml | 10 +++++++ debian/scripts/koha-create | 67 ++++++++++++++++++++++++++++++++++----------- 2 files changed, 61 insertions(+), 16 deletions(-) diff --git a/debian/docs/koha-create.xml b/debian/docs/koha-create.xml index 99ce191..7fb7956 100644 --- a/debian/docs/koha-create.xml +++ b/debian/docs/koha-create.xml @@ -37,6 +37,8 @@ /path/to/passwd database n + | + instancename @@ -149,6 +151,14 @@ + + , + + Print usage information. + + + + diff --git a/debian/scripts/koha-create b/debian/scripts/koha-create index 2c9752c..427e959 100755 --- a/debian/scripts/koha-create +++ b/debian/scripts/koha-create @@ -19,15 +19,49 @@ set -e -usage="Usage: $0 [--create-db|--request-db|--populate-db|--use-db] \ - [--marcflavor marc21|normarc|unimarc] \ - [--zebralang en|es|fr|nb|ru|uk] \ - [--auth-idx dom|grs1] [--biblio-idx dom|grs1] \ - [--use-memcached] \ - [--memcached-servers server:port] [--memcached-prefix prefix] \ - [--defaultsql /path/to/some.sql] \ - [--configfile /path/to/config] [--passwdfile /path/to/passwd] \ - [--database database] [--adminuser n] instancename" +usage() +{ + local scriptname=$0 + cat <&2 @@ -220,9 +254,9 @@ then . /etc/koha/koha-sites.conf fi -[ $# -ge 2 ] && [ $# -le 16 ] || die $usage +[ $# -ge 2 ] && [ $# -le 16 ] || ( usage ; die "Error: wrong parameters" ) -TEMP=`getopt -o crpm:l:d:f:b:a: -l create-db,request-db,populate-db,use-db,use-memcached,marcflavor:,auth-idx:,biblio-idx:,zebralang:,defaultsql:,configfile:,passwdfile:,database:,adminuser:,memcached-servers:,memcached-prefix:, \ +TEMP=`getopt -o chrpm:l:d:f:b:a: -l create-db,request-db,populate-db,use-db,use-memcached,help,marcflavor:,auth-idx:,biblio-idx:,zebralang:,defaultsql:,configfile:,passwdfile:,database:,adminuser:,memcached-servers:,memcached-prefix:, \ -n "$0" -- "$@"` # Note the quotes around `$TEMP': they are essential! @@ -257,11 +291,11 @@ while true ; do CLO_MEMCACHED_PREFIX="$2" ; shift 2;; -m|--marcflavor) CLO_ZEBRA_MARC_FORMAT="$2" ; shift 2 ;; - -l|--zebralang) + -l|--zebralang) CLO_ZEBRA_LANGUAGE="$2" ; shift 2 ;; - --auth-idx) + --auth-idx) CLO_AUTHORITIES_INDEXING_MODE="$2" ; shift 2 ;; - --biblio-idx) + --biblio-idx) CLO_BIBLIOS_INDEXING_MODE="$2" ; shift 2 ;; -d|--defaultsql) CLO_DEFAULTSQL="$2" ; shift 2 ;; @@ -273,6 +307,8 @@ while true ; do CLO_DATABASE="$2" ; shift 2 ;; -a|--adminuser) CLO_ADMINUSER="$2" ; shift 2 ;; + -h|--help) + usage ; exit 0 ;; --) shift ; break ;; *) @@ -341,8 +377,7 @@ Please set USE_MEMCACHED="yes" on /etc/koha/koha-sites.conf or use the EOF` - echo $usage - die $MSG + usage ; die $MSG else # Unset memcached-related variables MEMCACHED_SERVERS="" -- 1.8.3.2