Project

General

Profile

Revision 15ed27d8

Added by Julien Enselme over 9 years ago

Use getopts to print help and to parse script arguments.

View differences:

bin/d7-delete-site.sh
1 1
#!/bin/sh
2 2

  
3
. /home/assos/bin/scripts-config.sh
4
. scripts-config-site.sh "$1"
5
. scripts-utils.sh
3
usage() {
4
    echo "d7-delete-site.sh -s site_name."
5
}
6 6

  
7
help="# ARGS: site name."
7
site_name=''
8
while getopts "hs:" opt; do
9
    case "${opt}" in
10
	h)
11
	    usage; exit 0;;
12
	s)
13
	    site_name="${OPTARG}";;
14
	:)
15
	    echo "Option -$OPTARG requires an argument." >&2
16
	    usage >&2; exit 1;;
17
	\?)
18
	    usage >&2; exit 1;;
19
    esac
20
done
21
shift $((OPTIND-1))
8 22

  
9
check_arguments "$#" 1 "${help}"
23
. /home/assos/bin/scripts-config.sh
24
. scripts-config-site.sh "${site_name}"
25
. scripts-utils.sh
10 26

  
11 27
echo 'Awaiting for git status. (may take a while)'
12 28
if ! work_tree_clean ; then

Also available in: Unified diff