Rename gcutils to gc-utils to not confuse people.
[gc-utils.git] / gc-utils.sh
blob9b7f4c424f76af8776fa785447de950a058891d7
1 #!/bin/sh
2 # Copyright (c) 2008 David Soria Parra <dsp at php dot net>
4 # Licensed under the terms of the MIT License
5 # See /usr/share/doc/gcutils/copyright
6 # or http://www.opensource.org/licenses/mit-license.php
7 VERSION="$VERSION$"
8 PROGNAME="$PROGNAME$"
10 check_git ()
13 git --version > /dev/null
15 if test $? != 0
16 then
17 echo >&2 "Git not found. It's either not installed or not in \$PATH"
18 exit 127
21 version=`git --version | grep -o "[12]\.[5-9]\.[0-9]"`
22 if test -z "$version"
23 then
24 echo "Wrong git version. $prog needs git 1.5.0 or higher, but "`git --version`" found."
25 exit 127
29 version ()
31 echo "$PROGNAME: "`basename $0`-$VERSION
34 COMMANDS="gc-commit gc-import gc-multi-commit gc-update"
36 if test $# -lt 1
37 then
38 echo "$PROGNAME: $VERSION"
39 echo "available commands"
40 for cmd in $COMMANDS
41 do
42 echo -n " " && whatis $cmd | cut -b 4-
43 done
44 echo
45 else
46 case "$1" in
47 -V)
48 version
50 help)
51 for cmd in $COMMANDS
53 if test "$cmd" = "gc-$2"
54 then
55 man $cmd
56 exit 0
58 done
59 echo "Command $2 not found" 1>&2
60 exit 127
63 for cmd in $COMMANDS
65 if test "$cmd" = "gc-$1"
66 then
67 shift
68 $cmd $*
69 exit 0
71 done
72 echo "Command $1 not found" 1>&2
73 exit 127
75 esac